Dear Steven, If you remove the parameter: na.rm=TRUE then your example seems to work fine for me. Good luck!
Best wishes, Mark Mark Daniel Ward, Ph.D. Associate Professor and Undergraduate Chair Department of Statistics Purdue University 150 North University Street West Lafayette, IN 47907-2067 [email protected] phone: (765) 496-9563 On 9/9/14, 11:12 PM, Steven Stoline wrote:
Dear All: I was trying to get the lengths of vectors using "length" in tapply as follows: ni<-tapply(data[,2], data[,2], length, na.rm=TRUE) but it did not work for me. I am not sure what I am doing wrong. I am not sure if I should use different function. Here is the data: ============ data<-matrix(c(8,24,0,0,16,32,6,0,16,7,4,4,9,5,8,18,2,0,4,0,8,3,1,5,24,12,2,8,1,8, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,3,3),30,2) The answer should be: ni: 18 , 10 , 2 thank you very much Steven
_______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
