[R] Changing NA to 0 in selected columns of a dataframe

R. Michael Weylandt michael.weylandt at gmail.com
Fri Oct 12 01:04:09 CEST 2012


On Thu, Oct 11, 2012 at 11:58 PM, arun <smartpink111 at yahoo.com> wrote:
> Hi,
> Try this:
>  dat1 = as.data.frame ( cbind ( A, B, C, D, E ) )

No. Do not try this. It is a Very Bad Thing to use

as.data.frame(cbind(...))

instead of

data.frame(...)

for reasons I've mentioned before on this list. In short, cbind()
forces all its arguments to a single mode, thereby missing the entire
point of a data frame.

Cheers,
Michael




More information about the R-help mailing list