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?

1
  • 1
    R -e "some_r_functiion(); and_another_function()" Commented Oct 2, 2015 at 6:08

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

1 Comment

plotting doesn't seem to work with this approach. any idea on how I could make plotting also work?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.