You can use an "ifelse" statement in R - for info on syntax, I'd just type
?ifelse for help.
Quoting Jon Minton <jm540 at york.ac.uk>:
Isn?t ?countif? just a kind of condensed if/then
statement?
I think you could write a countif() function very easily.
From: gov2001-l-bounces at
lists.fas.harvard.edu
[mailto:gov2001-l-bounces at
lists.fas.harvard.edu] On Behalf Of
suerie_moon at
ksgphd.harvard.edu
Sent: 21 February 2007 20:59
To: gov2001-l at
lists.fas.harvard.edu
Subject: [gov2001-l] R equivalent of Excel "countif" function?
Hi all,
does anyone know if R has an equivalent to the "countif" function? I
searched the help directory but it doesn't seem too clear. If R does not
have a direct equivalent, is there an "if" type function one could use, and
does anyone have any bright ideas on how to do so?
Thanks in advance for any help,
-Suerie
-----gov2001-l-bounces at
lists.fas.harvard.edu wrote: -----
To: gov2001-l at
lists.fas.harvard.edu
From: hlk23 at
cornell.edu
Sent by: gov2001-l-bounces at
lists.fas.harvard.edu
Date: 02/21/2007 11:43AM
Subject: Re: [gov2001-l] Dataset in HW2
Alex,
type in
data <- as.data.frame(data)
to turn the matrix into a dataframe first. Or use data[,1] to
subset the cols of the matrix.
Holger
Alex Nicholas D'Amour wrote:
Hey all,
I'm trying to do the last question on the homework, but for some reason
I can't access the columns of the data frame in the normal way:
load("gov2001/data_ps2.RData")
data$pct.hispanic
NULL
Is there something I'm doing wrong?
Alex
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
HYPERLINK
"http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l"http://lists.fas.ha
rvard.edu/mailman/listinfo/gov2001-l
--
Holger Lutz Kern
Graduate Student
Department of Government
Cornell University
Institute for Quantitative Social Science
Harvard University
1737 Cambridge Street N350
Cambridge, MA 02138
www.people.cornell.edu/pages/hlk23
_______________________________________________
gov2001-l mailing list
gov2001-l at
lists.fas.harvard.edu
HYPERLINK
"http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l"http://lists.fas.ha
rvard.edu/mailman/listinfo/gov2001-l
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.18.3/694 - Release Date: 20/02/2007
13:44
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.18.3/694 - Release Date: 20/02/2007
13:44