[R] does there any function like sumif in excel?
djnordlund at verizon.net
Mon Sep 29 04:34:26 CEST 2008
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf
> Of caocheng??
> Sent: Sunday, September 28, 2008 7:26 PM
> To: R-help at r-project.org
> Subject: [R] does there any function like sumif in excel?
> I have a data.frame datas which have two columns A and B.
> I want to filter column A by some values and to get a value list which
> contain the value in B.
> Best wishes!
Not sure if I am interpreting you question correctly, but you could do something like
names(datas) <- c("A","B")
rslt <- datas[ datas[, 'A'] %in%(1:5) , ]
where datas[,'a'] %in%(1:5) is the example filter criteria that I used for the example. What is the nature of your data, and what are your filter criteria?
Bothell, WA USA
More information about the R-help