[R] TR : Probs with paste

EVANS David-William david-william.evans at sncf.fr
Tue Jun 10 13:33:36 CEST 2008


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



More information about the R-help mailing list