Or use [[ instead of [ (assuming you are only selecting one item) > tab <- table(c(16,16,17,17,17)) > c(n=1, seed=tab[2]) n seed.17 1 3 > c(n=1, seed=unname(tab[2])) n seed 1 3 > c(n=1, seed=tab[[2]]) n seed 1 3 > c(n=1, seed=tab[["17"]]) n seed 1 3
Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com > -----Original Message----- > From: William Dunlap > Sent: Wednesday, November 07, 2012 1:24 PM > To: 's...@gnu.org'; r-help@r-project.org > Subject: RE: [R] c weirdness > > Your example doesn't work here - you didn't show what 'tab' was. > Perhaps it was an output of table: > > > tab <- table(c(16,16,17,17,17)) > > c(n=1, seed=tab[2]) > n seed.17 > 1 3 > > c(n=1, seed=unname(tab[2])) > n seed > 1 3 > > Bill Dunlap > Spotfire, TIBCO Software > wdunlap tibco.com > > > > -----Original Message----- > > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > > Behalf > > Of Sam Steingold > > Sent: Wednesday, November 07, 2012 12:53 PM > > To: r-help@r-project.org > > Subject: [R] c weirdness > > > > is there a way to avoid c() appending ".0" and ".1" to seed? > > --8<---------------cut here---------------start------------->8--- > > > c("nons"=1, "seed"=3) > > nons seed ## good! > > 1 3 > > > c("nons"=1, "seed"=tab[1]) > > nons seed.0 ## don't want ".0"! > > 1 2344600 > > > c("nons"=1, "seed"=tab[2]) > > nons seed.1 ## don't want ".1"! > > 1 6843 > > > tab > > 0 1 > > 2344600 6843 > > --8<---------------cut here---------------end--------------->8--- > > > > -- > > Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X > > 11.0.11103000 > > http://www.childpsy.net/ http://pmw.org.il > > http://memri.org http://ffii.org http://openvotingconsortium.org > > Islam is a religion of Peace. Its adherents will kill anyone who disagrees. > > > > ______________________________________________ > > 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.