This question is similar to my previous question How to insert a python program into a bash script?. I am basically trying to achieve the same thing but with R. I tried the following
#!/bin/bash
R 1 2 3 4 << EOF
args<-commandArgs(TRUE)
for (i in args) {
print(i)
}
EOF
The output (as displayed when ran in R) should be:
[1] "1"
[1] "2"
[1] "3"
[1] "4"
The method of the answer to my previous question worked fine for python but not for R (which is what I expected). Is there a way to run R code within a a bash script as there is with python?