I am trying to run a script located here. The setup for which looks like this:
readlines <- function(...) {
lapply(list(...), readline)
}
input = readlines(
"Please Input Your Census API Key (Get a Free Census Api Key Here: <https://api.census.gov/data/key_signup.html>): ",
"Enter the State(s) you would like to use separated by a comma (i.e. Oregon, Washington) or enter USA if you want to calculate SVI for all 50 states: ",
"What Year would you like to calculate? (2009-2019 Are Available): ",
"Where would you like to save these files? Please type or copy and paste a complete file path: "
)
#**Install and load required packages**
API.key = input[[1]]
States = as.list(unlist(strsplit(input[[2]], split=",")))
Year = as.integer(input[[3]])
dir.create(paste0(gsub("\\\\", "/", input[[4]]), "/Social_Vulnerability"))
setwd(paste0(gsub("\\\\", "/", input[[4]]), "/Social_Vulnerability"))
My understanding is that I would replace the values after input=readlines( with the local info I have. So I rewrote it as:
readlines <- function(...) {
lapply(list(...), readline)
}
input = readlines(
"a952c5c861faf0ec64e05348e67xxxxxxxxxx", # "Please Input Your Census API Key (Get a Free Census Api Key Here: <https://api.census.gov/data/key_signup.html>): "
"USA", # "Enter the State(s) you would like to use separated by a comma (i.e. Oregon, Washington) or enter USA if you want to calculate SVI for all 50 states: "
"2009", # "What Year would you like to calculate? (2009-2019 Are Available): "
"C:/Users/FirstNameLastName/Data/Derived" #Where would you like to save these files? Please type or copy and paste a complete file path: "
)
#**Install and load required packages**
API.key = input[[1]]
States = as.list(unlist(strsplit(input[[2]], split=",")))
Year = as.integer(input[[3]])
dir.create(paste0(gsub("\\\\", "/", input[[4]]), "/Social_Vulnerability"))
setwd(paste0(gsub("\\\\", "/", input[[4]]), "/Social_Vulnerability"))
And I assume it's supposed to work where the readlines bit pulls in that info, and then drops it into the 1..[4].. spots as appropriate for API.key = input[1] etc. But, what input has saved after I ran the top bit is:
input
[[1]]
[1] "View(input)"
[[2]]
[1] "View(input)"
[[3]]
[1] "## R"
[[4]]
[1] "readlines <- function(...) {"
Which does not seem right at all. Any advice on where I am going wrong?