[R] an eval/parse trivia -- solved

Vincent Detours vdetours at ulb.ac.be
Thu Dec 11 12:59:59 CET 2003


> Is the data structure a factor variable containing character strings? 
> That would account for the lack of quotes and the "Levels" bit.  If so,
> try
> eval(parse(text=as.character(...))).

It works:

--------
> eval(parse(text=as.character(x)))
         NAS          NAS          IEA          IDA          NAS
ND
"GO:0004707" "GO:0005524" "GO:0004674" "GO:0006468" "GO:0000074"
"GO:0008372"
         IEA
"GO:0016740"
>
--------

Thank you very much!

Vincent 

 
> > x <- factor('structure(1:3, .Names=LETTERS[1:3])')
> > eval(parse(text=as.character(x)))
> A B C
> 1 2 3
> 
> Weird data structure to play with though - I agree with the "go back to
> the maintainers" comment ...
> 
> Cheers,
> Rich.
> 
> > Vincent  -
> >
> >>From the values shown, this looks like a Bioconductor question,
> > rather than base R.  You might try the maintainers of whatever
> > package the function comes from.
> >
> > Is 2287 the index in "levels" for one of the character strings
> > shown ?
> >
> > -  tom blackwell  -  u michigan medical school  -  ann arbor  -
> >
> > On Wed, 10 Dec 2003, Vincent Detours wrote:
> >
> >> Dear all,
> >>
> >> Any cue on how to evaluate x?
> >>
> >> > x
> >> [1] structure(c("GO:0004707", "GO:0005524", "GO:0004674",
> >> "GO:0006468", "GO:0000074", "GO:0008372", "GO:0016740"), .Names =
> >> c("NAS", "NAS", "IEA", "IDA", "NAS", "ND", "IEA"))
> >> 6204 Levels: GO:0000074 GO:0000158 GO:0000163 GO:0000166 ...
> >> structure(c("GO:0019538", "GO:0016706"), .Names =
> >> c("IEA", "IEA"))
> >> > parse(text=x) #a failed attempt
> >> expression(2287)
> >> > eval(parse(text=x))
> >> [1] 2287
> >> >
> >>
> >> Any idea? By the way why does parse return 2287?
> >>
> >> Thanks for your help,
> >>
> >> Vincent Detours
> >>
> >> ______________________________________________
> >> R-help at stat.math.ethz.ch mailing list
> >> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >>
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 
> 
>




More information about the R-help mailing list