[R] Converting "factors" to "numeric" in a dataframe
petr.pikal at precheza.cz
Thu Mar 18 13:04:11 CET 2010
as you did not provide data it is hard to say what is wrong.
You can see that it is working on dates similar what you described.
test <- data.frame(x=letters[1:10], y=rnorm(10), z=runif(10))
x y z
1 a 0.09980806 0.32211567
2 b 0.70559139 0.32204076
3 c -1.50514354 0.28267338
a b c d e f g
y 0.09980806 0.7055914 -1.5051435 0.4421971 0.1041789 -1.54683799
z 0.32211567 0.3220408 0.2826734 0.8819248 0.5189688 0.05171076
h i j
y 2.3137394 -0.4953507 0.7668954
z 0.7515886 0.5876854 0.4192073
Michael Glanville <michael.glanville19 at googlemail.com> napsal dne
> Thanks Petr, your suggestion has worked to a certain extent. The only
> that the sample names don't appear in the final dataframe. However, I
> persevere and see what I can do.
> Many thanks for you invaluable help,
> On 18 March 2010 11:23, Petr PIKAL <petr.pikal at precheza.cz> wrote:
> Hi Michael
> r-help-bounces at r-project.org napsal dne 18.03.2010 12:02:19:
> > Hi petr,
> > Thanks for the reply.
> > My original data is in "comma separated variable" (csv) format with
> > names in column 1 and numeric data in the remaining columns. The
> > command reads this data set into object name "pcrdata" as a dataframe
> > the variable names and numeric data are conserved (as required).
> So why not transpose only numeric part, then set it to data frame and
> column names from first column.
> Something like (untested)
> names(numdata) <- pcrdata[,1]
More information about the R-help