Dear Lockwood, As you can see, I'm a beginner...
But thank you very much! Sincerely, Tord Quoting "J.R. Lockwood" <[EMAIL PROTECTED]>: > how about > > buskartant$buskartant <- sapply( group.list, function(x) > sum(!is.na(unique(x))) ) > > OR > > buskartant$buskartant <- sapply( group.list, function(x) > length(unique(x[!is.na(x)])) ) > > > On Fri, 10 Jan 2003, Tord Snall wrote: > > > Date: Fri, 10 Jan 2003 15:19:18 +0100 > > From: Tord Snall <[EMAIL PROTECTED]> > > To: [EMAIL PROTECTED] > > Subject: [R] count levels per factor level > > > > Dear all, > > > > I would be really happy for help with the following because I will > treat > > many columns the same way. > > > > nlevels per ObjektID is what I want, but nlevels returns all levels > > occurring in cpy.busk$TradArt: > > > > buskartant<- aggregate(list(trash = cpy.busk$TradArt), list(ObjektID > = > > cpy.busk$ObjektID), nlevels) > > > > But as you can see I use it below anyway. I could use any function > instaed > > of nlevels beacuse now I just want the ObjektID in the right order. > > > > Greg Warnes kindly helped me with this solution: > > group.list <- split(cpy.busk$TradArt, cpy.busk$ObjektID) > > buskartant$buskartant <- sapply( group.list, function(x) > length(unique(x)) ) > > > > But the probelm is that unique considers NA as a category, and there > is no > > na.rm argument in unique(). > > > > Please give a hint. > > > > Thanks a lot in advance! > > > > Sincerely, > > Tord > > > > > ----------------------------------------------------------------------- > > Tord Sn�ll > > Avd. f v�xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet > > Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala > University > > Villav�gen 14 > > SE-752 36 Uppsala, Sweden > > Tel: 018-471 28 82 (int +46 18 471 28 82) (work) > > Tel: 018-25 71 33 (int +46 18 25 71 33) (home) > > Fax: 018-55 34 19 (int +46 18 55 34 19) (work) > > E-mail: [EMAIL PROTECTED] > > Check this: http://www.vaxtbio.uu.se/resfold/snall.htm! > > > ------------------------------------------------------------------------ > > > > ______________________________________________ > > [EMAIL PROTECTED] mailing list > > http://www.stat.math.ethz.ch/mailman/listinfo/r-help > > > > J.R. Lockwood > 412-683-2300 x4941 > [EMAIL PROTECTED] > http://www.rand.org/methodology/stat/members/lockwood/ > > ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
