[R] R dataframe question
arun
smartpink111 at yahoo.com
Sun Jan 26 01:16:23 CET 2014
Hi,
The question is not clear.
set.seed(45)
spe <- data.frame(Col1=sample(c(1:10,letters[1:2]),400,replace=TRUE))
mat1 <- matrix(spe[,1],nrow=20,ncol=20)
#If you want to replace the non-numeric values with NAs,
mat2 <- matrix(as.numeric(as.character(spe[,1])),nrow=20,ncol=20)
A.K.
Hello,
My data is in a 1 column x 40000 row data frame. I would like
to make it a 200 column x 200 row data frame. When I was using all
numeric values, I used the code below to transform my vector into a
matrix.
spematrix=data.matrix(spe)
matrix = matrix(spe, nrow = 200, ncol=200)
I cannot use this now though because my data contains non-numeric values.
I am new to R and would appreciate any help.
Thanks,
Mary
More information about the R-help
mailing list