Re: [R] long format with reshape

2013-01-24 Thread arun
HI, You could use: library(reshape)  res<-melt(dat,id.var=c("region","state")) names(res)[3:4]<-c("species","presence") res<-res[rev(order(res$region,res$state)),]  row.names(res)<- 1:nrow(res)  res   #  region state  species presence #1   sydney   nsw species3    1 #2   sydney   nsw species2 

Re: [R] long format with reshape

2013-01-24 Thread Gerrit Eichner
Hi, Daisy, try dat2 <- reshape( dat, varying = c( "species1", "species2", "species3"), v.name = "presence", timevar = "species", times = c( "species1", "species2", "species3"), direction="long") dat2[ rev( order( dat2$region)), ] Hth -- Ger