Reputation: 3531
I am using LaTeX and R to generate a geographical report. But I need to pass one text file as input. I need to run it on the Terminal using the following command:
R -e "Sweave('$PRGDIR/Test.Rnw')" <Input File> 1 0
Bu running on the Terminal is not a good practice while using an IDE (R-Studio). How can I do it using R-Studio?
Upvotes: 1
Views: 1874
Reputation: 360
I've had a similar problem, and the way I solved it was to create a variable in the shell call as follows:
R -e "file <- 'input_file.txt'; param1 <- 1; param2 <- 2; Sweave('$PRGDIR/Test.Rnw')"
within the .Rnw
script do a check to search for the variables using the exists
function:
if(exists("file")){
# do stuff here
} else{
stop('I Need a file!')
}
Upvotes: 1