You should pass the variables as command-line arguments in your Slurm script.
Then, modify Rscript.R to accept arguments.
This way, the Slurm script remains in Bash, and R receives the necessary variables as arguments.