Skip to content
R for the Rest of Us Logo

Objects and Functions

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Adapt your code from the last lesson so that it saves the data as an object called penguins_data

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Michelle Brodesky

Michelle Brodesky

March 13, 2024

I get the following error when trying to create the penguins_data object:

penguins_data <- read_csv("penguins_data.csv") Error in read_csv("penguins_data.csv") : could not find function "read_csv"

I can create the object if I use "read.csv", however. But, I can see that the tidyverse is loaded, so I'm not sure why the read_csv function can't be found.

David Keyes

David Keyes Founder

March 13, 2024

Can you clarify how you know that the tidyverse is loaded? This error very much sounds like the tidyverse has not been loaded so I want to make sure.

Michelle Brodesky

Michelle Brodesky

March 13, 2024

I can see tidyverse in the "packages" tab in the lower right panel of the interface, so I believe that means it's loaded? I can paste a screenshot on Discord if that would be helpful.

Michelle Brodesky

Michelle Brodesky

March 13, 2024

I can see tidyverse in the "packages" tab in the lower right panel of the interface, so I believe that means it's loaded? I can paste a screenshot on Discord if that would be helpful.

Libby Heeren

Libby Heeren Coach

March 13, 2024

Hey, Michelle! All installed packages will show up in the packages pane in RStudio, but only packages that have been loaded with the library() call will have a checkmark in the box next to them. I'll check in with you on Discord for extra help, but another way to check which packages have been loaded is to run loadedNamespaces(). The package you're looking for that contains read_csv() is the readr package.

Michelle Brodesky

Michelle Brodesky

March 13, 2024

Thank you! I ran library(tidyverse) and then everything worked as expected.

Derrick Watsala

Derrick Watsala

March 17, 2024

I would like you to help me confirm that once an Object appears in the Environment Panel, it's automatically saved. In this case our object is the penguins_data.

Libby Heeren

Libby Heeren Coach

March 17, 2024

Hi! When you run penguins_data <- read_csv("penguins_data.csv") it's saving the data object to your environment. This environment is temporary, so it's not saving a file to your computer, but rather saving an object for you to use during your R session. The penguins_data object will go away if you restart your R session, for instance.

Douglas Ndowo

Douglas Ndowo

March 21, 2024

Just to be clear, we see a lot of the word “penguins” in the codes so far just because the dataset we are using actually contains data on penguins 🐧. The word itself has nothing to do with R.

David Keyes

David Keyes Founder

March 22, 2024

Yes, your understanding is correct! We're using data from the palmerpenguins package, which is why you're hearing so much about penguins. If you're interested, here's the backstory of how this dataset came to be.