Passing variables and values from an R script to a shell script
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.