I an new to R (and think I always be). I am trying to wrangle the table resulting this code (only a very short example):
PlotA<-c(0,1,0,1,0,1,0,1,0,1)
PlotB<-c(0,0,1,1,0,0,1,1,0,0)
PlotC<-c(0,0,0,0,1,1,1,1,0,0)
PlotD<-c(0,0,0,0,0,0,0,0,1,1)
DF<-as.data.frame(cbind(PlotA,PlotB,PlotC,PlotD))
row.names(DF)<-paste0("Species",LETTERS[seq( from = 1, to = 10 )])
To this one (an example of only two plots out of the four):
SpeciesRepeat<-c("SpecisB","SpecisD","SpecisF","SpecisH","SpecisJ","SpecisC","SpecisD","SpecisG","SpecisH")
PlotRepeat<-c(rep("PlotA",length(PlotA [PlotA==1])), rep("PlotB",length(PlotB [PlotB==1])))
DesierdResDF<-cbind(SpeciesRepeat,PlotRepeat)
where every observation of a species in in a plot is represented in a row (obs). tidyverse and basic R code will both be appreciated
Thanks, Idan