Re: [R] a question to transform a dataframe empty 0/1

2013-06-20 Thread Arnaud Michel
Thank you arun ! I don't know the library reshape2 Michel Le 20/06/2013 19:55, arun a écrit : Hi, Not sure if you wanted the entries with "0". library(reshape2) dfMelt<-melt(df,id.var=c("Country","Iso")) #subset those with "1" dfNew<- subset(dfMelt,value==1,select=-4) row.names(dfNew)<- 1:

Re: [R] a question to transform a dataframe empty 0/1

2013-06-20 Thread arun
Hi, Not sure if you wanted the entries with "0". library(reshape2)  dfMelt<-melt(df,id.var=c("Country","Iso")) #subset those with "1" dfNew<- subset(dfMelt,value==1,select=-4) row.names(dfNew)<- 1:nrow(dfNew)  dfNew #    Country Iso   variable #1  Zimbabwe  ZW  Abaco #2  South Afri

[R] a question to transform a dataframe empty 0/1

2013-06-20 Thread Arnaud Michel
Hello I have the following dataframe : df <- data.frame( Country=c("Zimbabwe","Burkina Faso","South Africa","Madagascar","Tanzania", "Mali","Mozambique","Madagascar","Ghana","Nigeria","Kenya","Burkina Faso", "South Africa","Tanzania","Kenya","Ethiopia" ) , Iso=c("ZW","BF","ZA","MG","TZ","ML","M