Tim -
Another approach to your problem is to use xtabs:
xtabs(count~site+bug,data=myf)
bug
site grasshopper ladybug spider stinkbug
A 4 0 20
B 0 6 08
- Phil Spector
Hello, again.
Actually, you don't need to melt the data.frame, you can directly dcast
'myf' using value.var="count".
Rui Barradas
Em 20-06-2012 20:56, Rui Barradas escreveu:
Hello,
Try
library(reshape2)
mlt <- melt(myf, id=c("site", "bug"), measure="count")
myf2 <- dcast(mm, site ~ bug)
Hello,
Try
library(reshape2)
mlt <- melt(myf, id=c("site", "bug"), measure="count")
myf2 <- dcast(mm, site ~ bug)
myf2[is.na(myf2)] <- 0
myf2
Hope this helps,
Rui Barradas
Em 20-06-2012 19:58, Tim escreveu:
I am trying to learn how to reshape my data set. I am new to R, so please
bear wi
3 matches
Mail list logo