[R] of c, cat, paste, and lists??

Michaell Taylor nytaylor at bestweb.net
Thu Nov 29 20:16:17 CET 2001


Still trying to get a handle on c, cat, paste, and lists.

Here is my current problem.  I have a good number of vectors that I 
want to selectively combine into a dataframe.  The exact name of the 
vectors changes in a looping arrangement but can easily be grepped. The 
problem is: how can I use a list produced by a grep in a data.frame command: 
i.e.

> ls()
 [1] "a"            "a1"           "a2"           "a3"           "b3"
 [6] "c"            "compet1"      "compet10"     "compet2"      "compet3"
[11] "compet4"      "compet5"      "compet6"      "compet7"      "compet8"
[16] "compet9"      "d"            "g"            "h"            
"last.warning"
[21] "listing"      "pop1"         "pop10"        "pop2"         "pop3"
[26] "pop4"         "pop5"         "pop6"         "pop7"         "pop8"
[31] "pop9"         "s"            "vote1"        "vote10"       "vote2"
[36] "vote3"        "vote4"        "vote5"        "vote6"        "vote7"
[41] "vote8"        "vote9"        "X"

Now I want the "vote?" variables in a dataframe.  I can grep them by
> grep("vote",ls(),value=T)
 [1] "vote1"  "vote10" "vote2"  "vote3"  "vote4"  "vote5"  "vote6"  "vote7"
 [9] "vote8"  "vote9"

seems like some sort of:
mydata _ data.frame(as.list(grep("vote",ls(),value=T)))

should work, but doesn't.   The the list isn't being fed into the data.frame 
function properly, but I can't figure out how it needs to be feed.

Any help greatly appreciated.


=========================================
Curt Taylor
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list