Hi, I thought you were looking for table(), but the other answers gave you something really different; I might have wrongly understood your question.
HTH, Ivan Le 8/20/2010 12:32, Alain Guillet a écrit : > Hi, > > You can try sapply(levels(as.factor(dat1)),nchar) > > Alain > > On 20-Aug-10 12:01, Ron Michael wrote: >> Dear all, let suppose I have following vector: >> >>> dat1<- c(rep("asd", 5), rep("xyz", 12), rep("erd", 17)) >>> dat1<- dat1[sample(1:length(dat1), length(dat1), replace=F)] >>> dat1 >> [1] "erd" "xyz" "erd" "asd" "asd" "erd" "xyz" "asd" "erd" "erd" >> "asd" "xyz" "erd" "asd" "xyz" "xyz" "erd" "xyz" "erd" >> [20] "erd" "erd" "xyz" "xyz" "erd" "erd" "erd" "erd" "xyz" "xyz" >> "xyz" "erd" "xyz" "erd" "erd" >> >> Here I want to know the length of replications for each unique >> items viz "asd", "xyz", and "erd". Is there any R function available >> to directly implement that? >> Thanks, >> >> >> [[alternative HTML version deleted]] >> >> >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > -- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.