On Mon, Jun 13, 2011 at 6:47 PM, Aparna <aparna.sampat...@gmail.com> wrote:
> Hi Joshua
>
> While looking at the data, all the values seem to be in numeric. As i 
> mentioned,
> the dataset is already in data.frame.
>
> As suggested, I used str(mydata) and got the following result:
>
>
> str(leu_cluster1)
> 'data.frame':   984 obs. of  100 variables:
>  $ V2  : Factor w/ 986 levels "-0.00257361",..: 543 116 252 54 520 ...

your data columns are not numeric but factors indeed.
you may try this one

a <- as.character(rnorm(100))           # some numeric data
adf <- data.frame(matrix(a,10))         # which are misinterpreted as factors
adf
adf[,1]
class(adf[,1]) # check for the class of the first column
sapply(adf,function(x)class(x)) # check classes for all columns

b <- sapply(adf,function(x)as.numeric(as.character(x))) #
as.character: use levels literally, as.numeric: transforms in numbers
b # look at b

class(b) # which is now a numeric matrix

best regards

PF

-- 
+-----------------------------------------------------------------------
| Patrizio Frederic,
| http://www.economia.unimore.it/frederic_patrizio/
+-----------------------------------------------------------------------

______________________________________________
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.

Reply via email to