Re: [R] creating a data.frame from scratch

2019-04-23 Thread PIKAL Petr
Hi Structure is usefull for exchanging information and it is result of ?dput function. I wonder if anybody would like to use it for **creating** data frames. For creating data frames see functions like ?read.table, ?read.delim, or other ?read.* functions. Your questions are mainly adressed in

Re: [R] creating a data.frame from scratch

2019-04-19 Thread Jeff Newmiller
You seem to be trying to learn R ... sideways... or backwards, perhaps. Have you read An Introduction to R[1], included with every copy of the software? In particular, there are sections on data frames [2] (which should be read in the context of the discussion on lists, as it is presented. The

Re: [R] Creating a data.frame

2008-02-13 Thread Moshe Olshansky
Just make d <- data.frame(x,y,z). cbind forces x,y and z to be of the same type. --- Joe Trubisz <[EMAIL PROTECTED]> wrote: > OK...newbie question here. > Either I'm reading the docs wrong, or I'm totally > confused. > > Given the following: > > x<-c("aaa","bbb","ccc") > y<-rep(0,3) > z<-rep(0

Re: [R] Creating a data.frame

2008-02-13 Thread Ted Harding
On 13-Feb-08 22:17:32, Joe Trubisz wrote: > OK...newbie question here. > Either I'm reading the docs wrong, or I'm totally confused. > Given the following: > > x<-c("aaa","bbb","ccc") > y<-rep(0,3) > z<-rep(0,3) > > is.character(x) > [1] TRUE > > is.numeric(y) > [1] TRUE > > Now...I want to cre

Re: [R] Creating a data.frame

2008-02-13 Thread Andrew Robinson
Hi Joe, cbind coerces the data to be the same type. Much nicer is: d <- data.frame(x=x, y=y, z=z) Cheers Andrew On Wed, Feb 13, 2008 at 05:17:32PM -0500, Joe Trubisz wrote: > OK...newbie question here. > Either I'm reading the docs wrong, or I'm totally confused. > > Given the following: >

Re: [R] Creating a data.frame

2008-02-13 Thread Chuck Cleland
On 2/13/2008 5:17 PM, Joe Trubisz wrote: > OK...newbie question here. > Either I'm reading the docs wrong, or I'm totally confused. > > Given the following: > > x<-c("aaa","bbb","ccc") > y<-rep(0,3) > z<-rep(0,3) > > is.character(x) > [1] TRUE > > is.numeric(y) > [1] TRUE > > Now...I want to c

Re: [R] Creating a data.frame

2008-02-13 Thread Peter Alspach
Joe d <- data.frame(x=x, y=y, z=z) sapply(d, class) x y z "factor" "numeric" "numeric" d <- data.frame(x=x, y=y, z=z, stringsAsFactors=F) sapply(d, class) x y z "character" "numeric" "numeric" HTH Peter Alspach > -Origin