The thing to remember is that ifelse is a function,
it returns a value, so usually one does not need assignments within the
function call.

You also could do:
negindices <- dir=="-"
gc_content[negindices] <- -gc_content[negindices]

Eik Vettorazzi wrote:
> d <- ifelse(dir == "-", -gc_content , gc_content)
> works. You need not assign gc_content a new value in each comparison,  
> because then your "result" depends only on the last value of "dir", 
> which happened to be "-", so you got -0.5 for all gc_content.
> 
> hth
> 
-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to