Re: [R] Converting to mode numeric within a matrix

2007-09-28 Thread R Help
Your problem is that a matrix can't be a mix of data types, but a data frame can. Try the following code. newBest = as.data.frame(best) Now you can convert the column of numbers in newBest to numbers from the factors they start as. Check the help file for data.frame(...) for more details of how

[R] Converting to mode numeric within a matrix

2007-09-28 Thread Sergey Goriatchev
Hello, I create a matrix: best <- matrix(0, ncol=2, nrow=num.selected, dimnames=list(the.best$.Name, c("Probability(%)", "Inside"))) best[,1] <- as.numeric(the.best$Total*100) best[,2] <- ifelse(the.best$Weight==0, "No", "Yes") What I want is the second column of mode numeric, but it is of mod