[R] direct data frame entry

ivo welch ivo.welch at yale.edu
Wed Jun 9 21:29:59 CEST 2004

hi:  I searched the last 2 hours for a way to enter a data frame 
directly in my program.  (I know how to read from a file.)  that is, I 
would like to say something like

    d <- this.is.a.data.frame(   c("obs1name", 0.2, 0.3),
                                          c("obs2name", 0.4, 1.0),
                                          c("obs3name", 0.6, 2.0) , 
varnames=c("name", "val1", "val2")  );

everything I have tried sofar (usually, building with rbind and then 
names(d)) has come out with factors for the numbers, which is obviously 
not what I want.   this must be a pretty elementary request, so it 
should probably be an example under data.frame (or read.table).  of 
course, it is probably somewhere---just I have do not remember it and 
could not find it after 2 hours of searching.  I also tried the r-help 
archives---at the very least, I hope we will get the answer there for 
future lookups.

regards, /iaw

More information about the R-help mailing list