I tried to use this resource: How to print R variables in middle of String
and I still couldn't get to what I was looking for.
I'm looking to create a web scraper to run on a weekly basis, that scrapes seven web pages, each with a date. An example website (not real site for this posting) would be: "http://www.stevel.com/log/?xid=2275644&dd=2014-12-20". Therefore, I have seven dates and I want to create seven strings, inserting the dates at the end of the string.
#create dates needed
dates <- seq.Date(as.Date(Sys.Date() - 6) , Sys.Date(), by='days')
dates
[1] "2015-01-15" "2015-01-16" "2015-01-17" "2015-01-18" "2015-01-19" "2015-01-20"
[7] "2015-01-21"
my feeble attempt before creating a loop was trying to generate just one observation:
cat(sprintf("http://www.stevel.com/log/?xid=2275644&dd="\"%s"\, dates[1]))
desired final output would be:
[1] "http://www.stevel.com/log/?xid=2275644&dd=2015-01-15"
"http://www.stevel.com/log/?xid=2275644&dd=2015-01-16"
"http://www.stevel.com/log/?xid=2275644&dd=2015-01-17"
"http://www.stevel.com/log/?xid=2275644&dd=2015-01-18"
"http://www.stevel.com/log/?xid=2275644&dd=2015-01-19"
"http://www.stevel.com/log/?xid=2275644&dd=2015-01-20"
[7] "http://www.stevel.com/log/?xid=2275644&dd=2015-01-21"
the problem i clearly have in R in inserting a date into a string. any help to point me in the right direction would be greatly appreciated