Using R ======= Using RStudio -------------- Faculty makes data science in R easy by allowing you to easily use `RStudio `_, one of the best development environments for R. To start using R on Faculty, start a server and select R Studio under server type: .. image:: images/start_rstudio_server.png Once your server is up and running, simply click on the name of the server to open it in your workspace. Faculty uses RStudio server, which provides almost all of the functionality of RStudio installed on your desktop machine. To install packages such as `tidygraph`, simply open your RStudio server and run: .. code-block:: R install.packages('tidygraph') Plots are displayed in RStudio's plot viewer: .. code-block:: R library(ggplot2) ggplot(data=iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_point(size=3) .. thumbnail:: images/rstudio_server_open.png Installing packages via Faculty Environments -------------------------------------------- To install R packages in a reproducible way you can use the Faculty Environments feature. For example, to install the `tidygraph` and `shinydashboard` packages enter the following code snippet into the bash script section of any Faculty Environment .. code-block:: R R -e "withCallingHandlers(install.packages(c('tidygraph', 'shinydashboard'), repos='https://cran.rstudio.com/'), warning=function(w) stop(w))" The `withCallingHandlers` function call ensures that if there are errors whilst installing the packages the environment application will fail. .. thumbnail:: images/install_r_packages.png To find out more about Faculty features for your R workflow, take a look at these pages: * :ref:`rmarkdown-reports` * :ref:`rshiny-apps` * :ref:`plumber`