Re: [R] Grep with wildcards across multiple columns

2013-03-15 Thread arun
n   grepl(p1,v1) & grepl(p2,v2) to figure which entries in the table have v1 matching p1 and v2 matching p2. Or, you could use   intersect(grep(p1,v1), grep(p2,v2)) if you want to stick with integer indices. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- &g

Re: [R] Grep with wildcards across multiple columns

2013-03-15 Thread Bush, Daniel P. DPI
es in the table have v1 matching p1 and v2 matching p2. Or, you could use intersect(grep(p1,v1), grep(p2,v2)) if you want to stick with integer indices. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original Message- > From: r-help-boun...@r-project.org > [mail

Re: [R] Grep with wildcards across multiple columns

2013-03-14 Thread William Dunlap
#x27;year')]" , sep="") [1] "dt2 <- dt[grep('^1.E$', fund) & grep('^1.$', func) & grep('^...$', obj), sum(amount), by=c('code', 'year')]" Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -Original M

Re: [R] Grep with wildcards across multiple columns

2013-03-14 Thread arun
: 1002 2012 211499 aggregate(amount~code+year,data=df,sum) #  code year amount #1 1001 2011 185482 #2 1002 2011 238098 #3 1001 2012 189367 #4 1002 2012 211499 In the df, you provided, there is only value of obj. levels(df$obj) #[1] "100" A.K. - Original Message - From: "Bu

[R] Grep with wildcards across multiple columns

2013-03-14 Thread Bush, Daniel P. DPI
I have a fairly large data set with six variables set up like the following dummy: # Create fake data df <- data.frame(code = c(rep(1001, 8), rep(1002, 8)), year = rep(c(rep(2011, 4), rep(2012, 4)), 2), fund = rep(c("10E", "10E", "10E", "27E"), 4),