Why is it that the RScript works fine on RStudio but results in an error when running the crontab job on Terminal?
I'm trying to run a crontab job on an RScript to collect data every minute (* * * * *). The RScript works fine when run on RStudio however when running the crontab, I get the following error:
/Users/xx/Capstone_2/Get_Data.R: line 3: syntax error near unexpected token `'/Users/xx/Capstone_2/Data''
/Users/xx/Capstone_2/Get_Data.R: line 3: `setwd('/Users/xx/Capstone_2/Data')'
Here is what I run on crontab -e
:
* * * * * /Users/xx/Capstone_2/Get_Data.R
Here is the RScript:
setwd('/Users/xx/Capstone_2/Data')
library(twitteR)
setup_twitter_oauth('consumer-key', 'consumer-secret',
'access-token','access-secret')
iphonex <- searchTwitter("iphonex", n=1000)
iphonex <- twListToDF(iphonex)
write.csv(iphonex, '/Users/xx/Capstone_2/Data/iphonex.csv')
write.csv()
? – Len Greski Dec 3 '17 at 9:08