[R] problem in creating a dataframe
Hi I have a character class and i need to convert into dataframe data=(0,0,0,0) I want a dataframe with each one should under a separate column Please help me -- View this message in context: http://r.789695.n4.nabble.com/problem-in-creating-a-dataframe-tp4094676p4094676.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in creating a dataframe
I believe the command you are looking for is as.data.frame(), though you are probably going to need as.double() rather soon as well. Do note that data frames can, and often do, have character elements. Best, Michael On Nov 22, 2011, at 1:21 AM, arunkumar akpbond...@gmail.com wrote: Hi I have a character class and i need to convert into dataframe data=(0,0,0,0) I want a dataframe with each one should under a separate column Please help me -- View this message in context: http://r.789695.n4.nabble.com/problem-in-creating-a-dataframe-tp4094676p4094676.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] problem in creating a dataframe
Being new to R myself, I always get trapped by factors. Taking the data you have provided, this worked for my understanding of your intention: x - rep( 0, 4 ) x [1] 0 0 0 0 df - data.frame( matrix( x, 1 ), stringsAsFactors = FALSE ) df X1 X2 X3 X4 1 0 0 0 0 is.character( df[1,1] ) [1] TRUE Rgds, Rainer On Monday 21 November 2011 22:21:54 arunkumar wrote: Hi I have a character class and i need to convert into dataframe data=(0,0,0,0) I want a dataframe with each one should under a separate column Please help me -- View this message in context: http://r.789695.n4.nabble.com/problem-in-creating-a-dataframe-tp4094676p 4094676.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.