[R] Subsetting from data.frame

Göran Broström gb at stat.umu.se
Fri Nov 29 10:05:55 CET 2002


On Fri, 29 Nov 2002, Christian Schulz wrote:

> Hi,
>
> attach(data)
>
> if (TREUE[TREUE ==11] && EMPFEHL[EMPFEHL < 11])
> { TREUE <- EMPFEHL }
>
> what's wrong ( TREUE ==EMPFEHL works not,too )?

Use ifelse:

TREUE <- ifelse((TREUE == 11) & (EMPFEHL < 11), EMPFEHL, TREUE)

Note: & is the vectorizing 'AND'.

Göran
>
> many thanks & regards,Christian
>
>
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

---
 Göran Broström                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Umeå University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Umeå, Sweden             e-mail: gb at stat.umu.se


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