[R] Subsetting from data.frame

Ott Toomet otoomet at econ.dk
Fri Nov 29 11:27:52 CET 2002


Hi,

 | From: "Christian Schulz" <ozric at web.de>
 | Date: Fri, 29 Nov 2002 09:49:44 +0100
 | 
 | Hi,
 | 
 | attach(data)
 | 
 | if (TREUE[TREUE ==11] && EMPFEHL[EMPFEHL < 11])
 | { TREUE <- EMPFEHL }
 | 
 | what's wrong ( TREUE ==EMPFEHL works not,too )?
 | 
 | many thanks & regards,Christian

can you please give us more information?

I think what you want is

ind <- (TREUE == 11) & (EMPFEHL < 11)
TREUE[ind] <- EMPFEHL[ind]

Have you read about indexing, if and ifelse, & and &&?

Regards,

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