Basic Script

Until I figure out how to pin posts in a tag(?) here’s where my posts have gotten us so far with a starter script for BBS data. Start with the data tutorial before getting to this step to download North American BBS data. This script imports your data into R…

rm(list = ls()) 

BBS <- rbindlist(lapply(list.files("",full.names=TRUE),read.csv)) 
BBS$rteno <- paste(BBS$statenum,formatC(BBS$Route, width=3, flag="0"),sep="") 
speciesnames <- read.csv("SpeciesList.csv") 

routeinfo <- read.csv("weather.csv") 
routeinfo$rteno <- paste(routeinfo$statenum,formatC(routeinfo$Route, width=3, flag="0"),sep="") 
routeinfo <- routeinfo[c("RouteDataId","Year","ObsN","rteno","EndWind","StartWind","RunType","RPID")]
routeinfo$firstyear <- c(1L,routeinfo$ObsN[-1]!=routeinfo$ObsN[-nrow(routeinfo)])

BBS$countrynum <- NULL
BBS$rteno <- paste(BBS$statenum,formatC(BBS$Route, width=3, flag="0"),sep="") 
BBS$StopTotal <- NULL
BBS <- merge(BBS,routeinfo,by=c("rteno","Year"))

route_data <- read.csv("routes.csv")
route_data$rteno <- paste(route_data$statenum,formatC(route_data$Route, width=3, flag="0"),sep="") 
route_data <- route_data[c("BCR","rteno")]

BBS <- merge(BBS,route_data,by="rteno")
BBS <- BBS[BBS$BCR %in% c(), ]

Next, how about some co-variates? I have spatially related remote sensing data to BBS data.

Leave a Reply

Your email address will not be published. Required fields are marked *