3

From a bash script would I like to execute these R commands

install.packages('knitr', dependencies = TRUE)
install.packages("xlsx", dependencies="Depends")
install.packages("xtable")

One way would be to put them in a R file, then execute that, but I would prefer not to do that.

Can these commands be executed directly from a Bash script?

2
  • 8
    Try Rscript -e "..." (read Rscript man for details) or google for littler Commented Oct 8, 2015 at 14:44
  • Just use #!/usr/bin/env Rscript like you would use #!/bin/bash in an executable shell script. Commented Oct 8, 2015 at 14:51

1 Answer 1

2
apt-get -y install littler

echo 'install.packages("knitr", dependencies = TRUE, repos="http://cran.rstudio.com/")' | r

R -e can also be used.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.