[R] complex(?) reshaping question

hadley wickham h.wickham at gmail.com
Fri Dec 5 14:02:46 CET 2008


> I'm trying to omit NA:s in this DF and produce a reduced DF. The
> problem is that I cannot completely omit NA rows.
>
> I tried
>
> library(reshape)
> g <- melt(DF, id=c("idvar1", "idvar2"))
> g <- na.omit(g)

You're missing an id variable:

DF$idvar3 <- 1:2
g <- melt(DF, id=c("idvar1", "idvar2", "idvar3"), na.rm = T)
cast(g, idvar1 + idvar2 + idvar3 ~ variable)

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list