[R] Convert character string to number

2008-06-20 Thread Ken Liu
Hi, I would like to convert a character vector xxx - c(1/2, 1/4) to yyy - c(0.5, 0.25) , but as.numeric didn't work for me. Could anyone give me a hint please? Thanks, Ken __ R-help@r-project.org mailing list

[R] unable to update the matrix values within a function

2008-06-20 Thread Ken Liu
Hi, I don't understand why this doesn't work: matTest - matrix(nrow=3, ncol=3) testMove - function(I, J){ for(i in 1:I){ for(j in 1:J){ matTest[i, j] - i+j } } } testMove(2, 3) matTest Why the elements of the matrix matTest are still NA? How could I fix it?