[R] ifelse on data frames

MrJ Man auxsvr at yahoo.com
Fri Jan 5 18:12:01 CET 2007


On Friday 05 January 2007 12:34, Petr Pikal wrote:
> Hi
>
> you could use also another approach in case of data
frames
>
> A <- as.data.frame(A)
> A0 <- -A*log(A)
> A0[is.na(A0)] <- 0
I think you meant A0[which(is.na(A0))] <- 0
>
> which changes NaN's to zeroes
>
> HTH
> Petr
Regards



More information about the R-help mailing list