I'm trying to perform a conditional operation on a vector xt, given a value lambdat. Outside of the ifelse() function the operations work, but the full code doesn't. See example below, cheers!
xt <- c(1,2,3)
lambdat <- 1
bc_applied_columnt <- ifelse(lambdat != 0, (xt^(lambdat)-1)/lambdat, log(xt))
This returns 0 (first value in the vector xt), but I'd like it to return the output of (xt^(lambdat)-1)/lambdat or log(xt) - depending on the condition.
Aucun commentaire:
Enregistrer un commentaire