2

I'm working with a shell script(#!/bin/sh) and I wanted to know if there is a way to call variables with their values from an Rscript that I have called in my Shell script. If that doesn't make sense I want to create, for example a data frame data=data.frame(a=seq(1,5), b=seq(1,5)) in a script called test.r and then call that variable, with it's content in my shell script, i.e to print it with an echo:

echo $data

Spacedman
  • 2,042
  • 12
  • 17
Ka_Papa
  • 129
  • 3

1 Answers1

1

The Bash feature you want is called command substitution, e.g:

echo $(./test.r)

That will echo the output of your Rscript. Alternatively you could capture it in an environment variable.

Gaius
  • 328
  • 2
  • 11