On Sun, Sep 16, 2012 at 7:34 PM, Sam Steingold <s...@gnu.org> wrote: > Is it possible to violate the identity sum(table(v)) == length(v) ??
Quite easily: x <- c(1:5, NA) sum(table(x)) # 5 length(x) # 6 Perhaps look at the exclude= argument. Cheers, Michael > I see no way to do that and it holds in my small examples, > but it is violated in the huge set I have: > > system.time(z <- unique(data.frame(u=U,s=S))) > tab1 <- table(z$u) > tab1 <- tab1[tab1>0] # S is factor so some counts were 0 > tab2 <- table(z$s) > stopifnot(length(tab2) == nrow(z)) # yes > stopifnot(sum(tab1) == nrow(z)) ### no! > sum(tab1) > 728587 > length(tab1) > 503374 > length(tab2) > 2112951 > > -- > Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X > 11.0.11103000 > http://www.childpsy.net/ http://think-israel.org http://americancensorship.org > http://ffii.org http://memri.org http://jihadwatch.org http://pmw.org.il > Live Lisp and prosper. > > ______________________________________________ > 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. ______________________________________________ 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.