Skip to content
Prev 4414 / 15274 Next

Name of output column xts vs. dataframe using ifelse statement

Hi Ken,

I'm not sure there's any way for us to *fix* this, since it is a
result of the ifelse() function.  The source below shows the function
replaces the values of "test" with "yes" or "no" depending on the
result of "test".

Further, in the case that the result contains some values from *both*
columns x2 and x3, it's not clear what the column name should be.
function (test, yes, no) {
    storage.mode(test) <- "logical"
    ans <- test
    nas <- is.na(test)
    if (any(test[!nas]))
        ans[test & !nas] <- rep(yes, length.out = length(ans))[test & !nas]
    if (any(!test[!nas]))
        ans[!test & !nas] <- rep(no, length.out = length(ans))[!test & !nas]
    ans[nas] <- NA
    ans
}
<environment: namespace:base>


HTH,
Josh
--
http://www.fosstrading.com
On Sun, Jun 28, 2009 at 2:19 PM, Kenneth Spriggs<ksspriggs at gmail.com> wrote: