Skip to content

Instantly share code, notes, and snippets.

@ozjimbob
Created December 11, 2012 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozjimbob/4263494 to your computer and use it in GitHub Desktop.
Save ozjimbob/4263494 to your computer and use it in GitHub Desktop.
Testing
### Plot length summary
data=read.csv("plotBAincr.csv",stringsAsFactors=F)
data$Date.start=as.Date(data$Date.start)
data$Date.end=as.Date(data$Date.end)
plotlist=unique(data$Plot)
out_frame=data.frame(Plot="",Date.start="",Date.end="",length=0,stringsAsFactors=F)
for(the_plot in plotlist){
print(the_plot)
subdata=subset(data,Plot==the_plot)
datevec=c(subdata$Date.start,subdata$Date.end)
start=min(datevec)
end=max(datevec)
length=end-start
ins_vec=c(the_plot,as.character(start),as.character(end),length)
out_frame=rbind(out_frame,ins_vec)
}
out_frame=subset(out_frame,Plot!="")
write.csv(out_frame,"plot_lengths.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment