Installing R Packages

In R, you can install packages directly from within your script using the install.packages() function. For example, to install ggplot2, a popular package for data visualization, include the following line at the beginning of your script:

install.packages("ggplot2")

Before you install a package, make sure to set up your R environment with renv to manage dependencies and ensure reproducibility. See our page on renv for more details.

Installing RStudio

To install RStudio, an interactive environment for writing R scripts, please refer to the installation instructions on the RStudio site.