New to R and need help with error when using multiple packages at once

I am in the middle of a lesson in R and we are using the palmerpenguins dataset and the topic is how to pull up different variations of summarized data from a dataset (specifically glimpse(), skim_without_charts(), head(), and select().
As instructed the following packages were loaded in (via install.packages("") and then library()); "skimr", "dplyr", "janitor", and "here". And the packages; "tidyverse", "lubridate" from an earlier lesson. The dataset palmerpenguins has also already been added.

My issue is that I can't get glimpse(), or skim_without_charts() to work unless I go through the install.package() process with the related package in between each. For example, the code I had added in for this activity is:

install.packages("here")
library("here")
install.packages("skimr")
library("skimr")
install.packages("janitor")
library("janitor")
install.packages("dplyr")
library("dplyr")
install.packages("palmerpenguins")
library(palmerpenguins)
skim_without_charts(penguins)
**Error in skim_without_charts(penguins) : **
** could not find function "skim_without_charts"

install.packages("skimr")
install.packages("palmerpenguins")
library("skimr")
library("palmerpenguins")
skim_without_charts(penguins)
**SUCCESS - Data removed to save room on this forum post
glimpse(penguins)
**Error in glimpse(penguins) : could not find function "glimpse"
install.packages("dplyr")
library("dplyr")
install.packages("palmerpenguins")
library("palmerpenguins")
glimpse(penguins)
*SUCCESS - Data removed to save room on this forum post

In summation: I don't understand if I will always have to reload or install.packages() and library() in between skim_without_charts() and glimpse() types or if I am misunderstanding a piece of this puzzle. S.O.S.

1 Like

You only need to run install.packages() once, to install the package(s) on your machine.

Then, in your R script, or interactively, you need to run library() to load all the packages that you want to use in that script or session.

You need to use library(skimr) before using the skim_without_charts function. Same issue with glimpse, you need to load the relevant library before using the functions in the library.

Understood and per my example shown library(skimr) was used. My question is do I have to use library("skimr") every time I use skim_without_charts or should my RStudio not be having me input library("skimr") whenever I use it?

I am not grasping the lesson, if library() is supposed to only be needed once when loading it in or if that is part of the statement every time I want to use skim_without_charts or something similar? (For clarity, in the lesson and video they were not having to do this which is why I am having some confusion).

You only have to do install_packages() once. You have to do library() once in each session. A way to think about it is that install_packages() puts the package on your computer; library() brings the package into the current session.

Thank you so much! Trying to internalize the concepts one step at a time. :slight_smile: