Hi,
attach(data)
if (TREUE[TREUE ==11] && EMPFEHL[EMPFEHL < 11])
{ TREUE <- EMPFEHL }
what's wrong ( TREUE ==EMPFEHL works not,too )?
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Christian Schulz wrote:> > Hi, > > attach(data) > > if (TREUE[TREUE ==11] && EMPFEHL[EMPFEHL < 11]) > { TREUE <- EMPFEHL } > > what's wrong ( TREUE ==EMPFEHL works not,too )? > > many thanks & regards,ChristianNeither if() nor "&&" works vectorized, use ifelse() and "&" instead (see the help pages for details). Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._