Bioinformatics
biolerplate-notes
R Studio Docker

Here's a concise mini-documentation for using Rocker/RStudio in a blog format. You can customize it as needed for your audience!


Mini Documentation: Using Rocker/RStudio

Introduction

Rocker is a collection of Docker images designed for the R programming language, providing a robust environment for data science and statistical computing. The RStudio image is part of Rocker, allowing users to leverage the powerful RStudio IDE for a seamless coding experience. This documentation provides a quick guide on how to set up and use Rocker/RStudio for your R projects.

Prerequisites

Before getting started, ensure you have the following:

Getting Started

1. Pull the Rocker/RStudio Image

Open your terminal or command prompt and pull the latest Rocker/RStudio image:

docker pull rocker/r-ver:latest

You can replace latest with a specific R version (e.g., 4.3.0) if needed.

2. Run the RStudio Server

Run the RStudio Server container with the following command:

docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=yourpassword rocker/rstudio
  • -d runs the container in detached mode.
  • -p 8787:8787 maps the containerā€™s port 8787 to your local machineā€™s port 8787.
  • -e USER=rstudio sets the username.
  • -e PASSWORD=yourpassword sets the password for RStudio access.

3. Access RStudio

Open your web browser and navigate to:

http://localhost:8787

Log in using the username rstudio and the password you set in the previous step.

4. Install R Packages

Once logged in, you can install any R packages you need. Open the terminal within RStudio and run:

install.packages("dplyr") # Example package

You can install multiple packages at once:

install.packages(c("ggplot2", "tidyverse", "shiny"))

5. Save Your Work

To persist your work, create a volume when running the container:

docker run -d -p 8787:8787 -e USER=rstudio -e PASSWORD=yourpassword -v /path/to/your/local/directory:/home/rstudio rocker/rstudio

Replace /path/to/your/local/directory with the path where you want to save your projects on your local machine.

6. Stop and Remove the Container

To stop your RStudio server, find the container ID:

docker ps

Then stop the container:

docker stop <container_id>

To remove the container, run:

docker rm <container_id>

Conclusion

Using Rocker/RStudio allows you to create a consistent and reproducible R environment for your data science projects. Whether you're working on data analysis, visualization, or statistical modeling, this setup provides a powerful platform for your R development needs.

For more detailed information and advanced usage, check out the Rocker Project Documentation (opens in a new tab).


Feel free to adapt this template according to your blog's style and audience!