On 9/17/07, snapperball <[EMAIL PROTECTED]> wrote: > I am using a number of large matrices in a project. I read a couple of the > matrices using the read.csv command. However in some instances, R does not > recognize the resulting matrices as consisting of numerical values (I > suspect R considers them as strings or factors) > > for instance when I try the following command (consider aMatrix is a > matrix), > > > range(aMatrix[,1]) > > R returns > > > NA > > I get the same output when I try the max and min commands. Basically R does > not recognise the matrix as consisting of numerals. However when I inspect > the matrix the entries appear to contain numerical values. > > Is there something I am doing wrong? Is there anyway of coercing R into > recognizing the matrix as consisting of numerals?
Use as.numeric: > m <- matrix(c("1","2","3","4"),2,2) > m [,1] [,2] [1,] "1" "3" [2,] "2" "4" > range(as.numeric(m[,1])) [1] 1 2 Paul ______________________________________________ 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.