Look at ?get and possibly ?Filter (new to 2.6.0), do they help with what you want?
-- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Steve Powers > Sent: Wednesday, November 07, 2007 4:42 PM > To: Peter Alspach > Cc: r-help@r-project.org > Subject: Re: [R] creating a dynamic output vector > > Not exactly. That doesn't work for me. Because I don't > actually know what variables are created each time I run the > program, I don't have an easy way to call all the ones I need > at once (which your suggestion appears to require). But I do > have a list of names for all the variables I want. We need to > match based on variable names I think. > > Note that elements of NAMES correspond to exact variables, > but with quotes around them. > > If I just knew how to tell R to call NAMES[1], NAMES[2], > NAMES[3] etc., but without quotes (so that the variable > itself is called, rather than the header string), that might > work. But when NAMES[1]="varA," the code / noquote(NAMES[1])/ > > literally returns /varA/, rather than the desired > value/string that comes out when I manually type the code > varA. Weird.---steve > > > > > Peter Alspach wrote: > > Steve > > > > Is this the sort of thing you mean? > > > > output <- character(26) > > names(output) <- paste('var', LETTERS[1:26], sep='') > > output > > output[paste('var', LETTERS[c(2,4,6,7,16)], sep='')] <- c(1, pi, > > letters[1:3]) > > output > > > > Peter Alspach > > > > > >> -----Original Message----- > >> From: [EMAIL PROTECTED] > >> [mailto:[EMAIL PROTECTED] On Behalf Of Steve Powers > >> Sent: Thursday, 8 November 2007 11:27 a.m. > >> To: r-help@r-project.org > >> Subject: [R] creating a dynamic output vector > >> > >> Let's say I have a program that returns variables whose names > >> may be any string within the vector > >> NAMES=c("varA","varB","varC","varD","varE","varF"..."varZ"), > >> but I do not ever know which ones have actually been created. > >> So in one example output, "varA", "varC", and "varD" could > >> exist, but in another example output "varA", "varD", > >> "varE",and "varF" exist, with no pattern or predictability > >> (different combinations can come out, as well as different > >> numbers of variables). > >> > >> How do assign the output values, in pre-arranged order, into > >> an output vector? The output vector for the first example > >> would be OUTPUTS=c(varA, NA, varC, varD...) and the output > >> vector for the second example would be OUTPUTS=c(varA, NA, > >> NA, varD, varE, varF...). In other words, the rows for all > >> potential returned values need to be retained in the order > >> set by NAMES, and the values all need to be plugged into > >> their respective spot in that order if they exist. Otherwise > >> NA is plugged in. > >> > >> One other factor is that some outputs are values, but others > >> are text. Tips? > >> > >> > >> Using R version 2.4 on Windows XP > >> > >> ______________________________________________ > >> 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. > ______________________________________________ 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.