[R] TR : Probs with paste

From: EVANS David-William <david-william.evans_at_sncf.fr>
Date: Tue, 10 Jun 2008 13:33:36 +0200


Thanks for the messages. What I probably should have explained is that I have a data.frame "file" with variables named "A", "B", etc.. I wanted to use paste () to pull the names "file$A", "file$B", etc. and stick them in table() and so get an output of table(file$A). For the record, someone read my thinking and sent the following solution which works well:

        table(eval(parse(text=risk.factors[1])))

Thanks again. David.

-----Message d'origine-----
De : Sarah Goslee [mailto:sarah.goslee_at_gmail.com] Envoyé : lundi 9 juin 2008 21:00
À : EVANS David-William
Objet : Re: [R] Probs with paste

As another poster said, you didn't actually tell us what you wanted. But I wouldn't be at all surprised if ?get is just what you're looking for.

Sarah

On Mon, Jun 9, 2008 at 10:44 AM, EVANS David-William <david-william.evans_at_sncf.fr> wrote:
> Hello all,
>
>
>
> After some months doing ok with R, I am embarrassed that I have to make
> this my first posting to the help list. I am trying to run the
> following (actually in a loop but shortened for the post):
>
>
>
> risk.factors <- c("file$A", "file$B", "file$C", "file$D", "file$E")
>
> table(paste(risk.factors[1]))
>
>
>
> but run into problems with the table (paste...) line as I get the
> following output:
>
>
>
>> table(paste(risk.factors[1]))
>
>
>

-- 
Sarah Goslee
http://www.functionaldiversity.org

______________________________________________
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.
Received on Tue 10 Jun 2008 - 12:16:01 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 10 Jun 2008 - 12:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive