Created
March 19, 2022 09:22
-
-
Save skngetich/b5550975aaf4ae2304370c0e836d5a3a to your computer and use it in GitHub Desktop.
This code snippet code install packages if it does not exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clear all variables in work space and install packages | |
```{r message = FALSE,warning = FALSE} | |
# Clears environment | |
rm(list=ls()) | |
# Add packages needed in the project | |
requiredPackages = c('quantmod','TTR','tseries') | |
for(p in requiredPackages){ | |
if(!require(p,character.only = TRUE)) install.packages(p) # Install package if it does not exist | |
library(p,character.only = TRUE) | |
} | |
``` |
Alternative Method 3:
install.packages("pacman")
pacman::p_load(ggplot2, tidyr, dplyr)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative Method 2: