Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a "Fun Fact" about pacman package in Speaking R's Language #168

Open
G1ngie opened this issue Aug 29, 2024 · 0 comments
Open

Adding a "Fun Fact" about pacman package in Speaking R's Language #168

G1ngie opened this issue Aug 29, 2024 · 0 comments

Comments

@G1ngie
Copy link

G1ngie commented Aug 29, 2024

I don't know how you would put this in, but when I first learned R, I found it really annoying typing "library()" over and over. Then, a professor taught me about the pacman package and p_load, where it checks to see if the package is installed first, installs it if it isn't, and then runs the library function. I put this code at the top of all my scripts:

# Check for pacman package
if (!require("pacman")
) install.packages("pacman")

# Packages
pacman::p_load(
  #add list of packages here

)

The packages are just comma-separated, making for much cleaner code. I wish someone had taught me this tip much earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant