1

I need to Run R interpreter within a shell script an issue some predefined R commands through the shell script. Is this possible?

Right now I have a shell script as follows.

#!/bin/bash

echo "Starting R"

R

This starts an interactive R shell. Now I need to issue some R commands using the same shell script. any ideas?

DesirePRG
  • 6,122
  • 15
  • 69
  • 114

1 Answers1

1

You can use a here document:

... bash stuff
...
/usr/bin/R --no-save << EOT
x<-2*pi*(0.1*(0:10))
print(cbind(x,sin(x)))
quit("no")
EOT
...
... bash stuff
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432