Skip to content

Instantly share code, notes, and snippets.

@troyhill
Last active September 17, 2018 16:59
Show Gist options
  • Save troyhill/d0ad75a4cb38b11c2be550306e60530d to your computer and use it in GitHub Desktop.
Save troyhill/d0ad75a4cb38b11c2be550306e60530d to your computer and use it in GitHub Desktop.
R-bash integration: R script
#!/usr/bin/Rscript
### Download NOAA station data
### First, check if VulnToolkit is installed, install if it's not
list.of.packages <- c("devtools", "VulnToolkit")
new.packages <- list.of.packages[!(list.of.packages %in%
installed.packages()[,"Package"])]
if ("devtools" %in% new.packages) {
install.packages("devtools")
devtools::install_github("troyhill/VulnToolkit")
} else if ("VulnToolkit" %in% new.packages) {
devtools::install_github("troyhill/VulnToolkit")
}
library(VulnToolkit)
### download NOAA data
targetStation <- commandArgs()[6]
exported_filename <- paste0(commandArgs()[7], "/", targetStation, ".csv")
noaaDat <- noaa(targetStation, begindate = 20170101, enddate = 20180101)
write.csv(noaaDat, file = exported_filename, row.names = FALSE)
cat(paste0("Station no. ", targetStation, " saved to ", exported_filename, "\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment