I have the data below in a dataset called test3.
What is the easiest way to get a count, by date, of all numerical values of
var1, and to then add this count to the test3 dataset as a new column?
What I have:
date,var1,cat
1/1/2005,5,a
1/1/2005,12,a
1/1/2005,44,b
2/1/2005,1,b
2/1/2005,8,a
2/1/2005,32,z
2/1/2005,44,a
3/1/2005,5,z
3/1/2005,7,e
3/1/2005,95,s
3/1/2005,95,s
1/1/2005,NA,NA
1/1/2005,4,NA
1/1/2005,5,NA
3/1/2005,NA,NA
4/1/2005,NA,a
what I want:
date,var1,cat,n
1/1/2005,5,a,5
1/1/2005,12,a,5
1/1/2005,44,b,5
2/1/2005,1,b,4
2/1/2005,8,a,4
2/1/2005,32,z,4
2/1/2005,44,a,4
3/1/2005,5,z,4
3/1/2005,7,e,4
3/1/2005,95,s,4
3/1/2005,95,s,4
1/1/2005,NA,NA,5
1/1/2005,4,NA,5
1/1/2005,5,NA,5
3/1/2005,NA,NA,4
4/1/2005,NA,a,0
---------------------------------
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html