If you also favor to use the function, be aware of the returned value. For example:
Here is another nice example (from http://rwiki.sciviews.org/doku.php?id=tips:programming:ifelse)
Here is another nice example (from http://rwiki.sciviews.org/doku.php?id=tips:programming:ifelse)
> varD <- log(0:9) # A vector like this one that contains -Inf could be troublesome in subsequent manipulations > varD [1] -Inf 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595 [8] 1.9459101 2.0794415 2.1972246 > varD <- ifelse(is.finite(varD), varD, NA) # Remove the -Inf, replace with NA > varD [1] NA 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595 [8] 1.9459101 2.0794415 2.1972246
No comments:
Post a Comment