Displaying 1 result from an estimated 1 matches for "conveluted".
2006 Jan 13
1
better way to replace missing values with zero
...like below--where
ever they may be--but some of the column classes are non-numeric so I get an
error:
> dim(temp)
[1] 699 313
> temp[is.na(temp)] <- 0
Error in as.Date.default(value) : do not know how to convert 'value' to
class "Date"
>
So I have to use more conveluted code:
for (k in c(1:ncol(temp))) {
if (class(temp[, k])=="numeric") {
temp[, k][is.na(temp[, k])] <- 0
}
}
This is much more code and requires a for loop. Can anyone please show me a
better way?
Thanks,
Roger...