[R] subset of matrix vs data frame
Denis White
denis at mail.cor.epa.gov
Wed May 31 20:29:53 CEST 2000
In Splus this works,
> a <- data.frame(matrix(round(runif(10),0),nrow=2,ncol=5))
> a[a == 1] <- 2
but in R only if a is matrix,
> a[a == 1] <- 2
Error in [<-.data.frame(*tmp*, a == 1, value = 2) :
matrix subscripts not allowed in replacement
Was this a design decision? Sorry if I missed it in
An Introduction to R.
Denis
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list