Skip to content
Back to formatted view

Raw Message

Message-ID: <Pine.SUN.3.91.1000531112236.7667H-100000@okapi.cor.epa.gov>
Date: 2000-05-31T18:29:53Z
From: Denis White
Subject: subset of matrix vs data frame

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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._