[R] Converting to mode numeric within a matrix

Sergey Goriatchev sergeyg at gmail.com
Fri Sep 28 16:24:08 CEST 2007


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 mode
character, despite the attempt to convert it to numeric with
as.numeric(). It must have something to do with the second column of
the matrix, where I write No/Yes.
What should I do to have the first column of mode numeric?
Also, how can I output No/Yes in the second column without citation
marks around them?

Thanks in advance

More information about the R-help mailing list