Skip to content

Instantly share code, notes, and snippets.

@aurielfournier
Created October 19, 2022 19:52
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 aurielfournier/17b3d180b4030ade60d07bd21497cafb to your computer and use it in GitHub Desktop.
Save aurielfournier/17b3d180b4030ade60d07bd21497cafb to your computer and use it in GitHub Desktop.
library(stringr)
library(tidyverse)
fromdat <- data.frame(site = c("syr1","syr2","syr3"),
date1 = c("01/02/22","02/03/2022", "datestuff"),
temp1 = c(35),
count1 = c(4,5,6),
date2 = c("date2stuff"),
temp2 =c(37),
count2 = c(99,100,101))
numlist <- list()
for(i in seq(from=2,to=5, by=3)){
thing <- fromdat[,c(1,i:(i+2))]
colnames(thing) <- c("site","date","temp","count")
numlist[[i]] <- thing
}
todat <- do.call(rbind, numlist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment