search for: testvar1

Displaying 2 results from an estimated 2 matches for "testvar1".

Did you mean: testvar
2011 Oct 05
2
aggregate function with a dataframe for both "x" and "by"
...ntains information on the "group" each row of the data is in. I wish to aggregate each column in mydata using the corresponding column in mybys. Please see the example below. What is a more elegant or "better" way to accomplish this task? Thanks! mydata = data.frame(testvar1=c(1,3,5,7,8,3,5,NA,4,5,7,9), testvar2=c(11,33,55,77,88,33,55,NA,44,55,77,99) ) mybys=data.frame(mbn1=c('red','blue',1,2,NA,'big',1,2,'red',1,NA,12),mbn2=c('wet','dry',99,95,NA,'damp',95,99,'red',99,NA,NA) , stringsAsFactors =F) m...
2007 Jul 31
1
aggregate.data.frame - prevent conversion to factors? show statistics for NA values of "by" variable?
...formatted as "factors". Is there a way to prevent this, and to instead have them retain the format in the original "mybys" data.frame (i.e to have them come back formatted as "character"? Or do I just need to re-format them once I have my results? mydf=data.frame(testvar1=c(1,3,5,7,8,3,5,NA,4,5,7,9), testvar2=c(11,33,55,77,88,33,55,NA,44,55,77,99) ) str(mydf) # myby1=c('red','blue',1,2,NA,'big',1,2,'red',1,NA,12) myby2=c('wet','dry',99,95,NA,'damp',95,99,'red',99,NA,NA) myby1.new = ifelse(is.na(myby...