Sorry for this dumb question. Suppose I have a named array ww defined as ww <- 1:5 names(ww) <- c("a", "b", "c", "d", "e") How can I extract the whole array of numbers without the names? ww[1:5] does not work while ww[[1]] can only extract one number at a time. Thanks, Gang
Gang Chen wrote:> Sorry for this dumb question. Suppose I have a named array ww defined as > > ww <- 1:5 > names(ww) <- c("a", "b", "c", "d", "e") > > How can I extract the whole array of numbers without the names? > ww[1:5] does not work while ww[[1]] can only extract one number at a > time.Use as.vector to strip these attributes: as.vector(ww)> Thanks, > Gang > > ______________________________________________ > R-help at 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.
Try: as.numeric(ww) On Mon, Apr 7, 2008 at 1:33 PM, Gang Chen <gangchen6@gmail.com> wrote:> Sorry for this dumb question. Suppose I have a named array ww defined as > > ww <- 1:5 > names(ww) <- c("a", "b", "c", "d", "e") > > How can I extract the whole array of numbers without the names? > ww[1:5] does not work while ww[[1]] can only extract one number at a > time. > > Thanks, > Gang > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Thanks a lot for the suggestions! Gang On 4/7/08, Uwe Ligges <ligges at statistik.tu-dortmund.de> wrote:> > > Gang Chen wrote: > > > Sorry for this dumb question. Suppose I have a named array ww defined as > > > > ww <- 1:5 > > names(ww) <- c("a", "b", "c", "d", "e") > > > > How can I extract the whole array of numbers without the names? > > ww[1:5] does not work while ww[[1]] can only extract one number at a > > time. > > > > > Use as.vector to strip these attributes: > > as.vector(ww)