Re: [R] Do NOT use ifelse() if you can use if(.) else . [was "Checking .."]

2014-12-23 Thread Ben Tupper
On Dec 23, 2014, at 4:05 AM, Martin Maechler wrote: >> Steven Yen >>on Sun, 14 Dec 2014 09:30:56 -0500 writes: >> Steven Yen >>on Sun, 14 Dec 2014 09:30:56 -0500 writes: > >> Thanks. This worked!! :) >> Fisher <- ifelse(!("Fisher" %in% names(obj$spec)), FALSE, obj$spec

Re: [R] Do NOT use ifelse() if you can use if(.) else . [was "Checking .."]

2014-12-23 Thread John Fox
Hi, Sorry to chime in late, but here's an alternative solution, without conditionals: > obj <- list(spec=list("Fisher"=TRUE, "Tukey"=FALSE)) > obj$spec$Fisher [1] TRUE > !is.null(obj$spec$Fisher) && obj$spec$Fisher [1] TRUE > obj$spec$Pearson NULL > !is.null(obj$spec$Pearson) && obj$spec$

Re: [R] Do NOT use ifelse() if you can use if(.) else . [was "Checking .."]

2014-12-23 Thread peter dalgaard
> On 23 Dec 2014, at 10:05 , Martin Maechler wrote: > > > In cases like this one when the condition 'Cond' is a > simple TRUE or FALSE (i.e. of length 1), using > > if(Cond) A else B > > instead of > > ifelse(Cond, A, B) > > is > > 1. much more R - like [[ "everything you do

[R] Do NOT use ifelse() if you can use if(.) else . [was "Checking .."]

2014-12-23 Thread Martin Maechler
> Steven Yen > on Sun, 14 Dec 2014 09:30:56 -0500 writes: > Steven Yen > on Sun, 14 Dec 2014 09:30:56 -0500 writes: > Thanks. This worked!! :) > Fisher <- ifelse(!("Fisher" %in% names(obj$spec)), FALSE, obj$spec$Fisher) "worked", yes. But please --- for the mai