FAQ: Introduction to R Syntax - Importing Packages

This community-built FAQ covers the “Importing Packages” exercise from the lesson “Introduction to R Syntax”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn R

FAQs on the exercise Importing Packages

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

There’s a typo in the first line of the prompt.
“R’s popoularity is also largely due to the many fantastic packages available in the language!”

Does it matter where you type the code to import a package? Does it have to be at the top or can it be anywhere?


How do we know the packages have been installed in the notebook already? (The directions have us skip straight to import(package-name) Do we just assume that because it’s in the instructions, it’s already there?

1 Like

Yes it does matter. I actually put it in the end, and it didn’t work at all. So we always have to put in the beginning I guess.

Wait, is this a tip for python? What is R syntax

The solution to this exercise is very finicky.
I was doing the following because the exercise lists dplyr before readr

# load libraries

but it wasn’t working. apparently the answer is just switched around for some reason, even though
both should work just fine


# load libraries

I have a question about the head() function that is used in line 17. Why does the output have only 6 rows (No Rolling Stones) when the function only specifies head(artists) instead of head(artists, 6)? Thanks in advance!

the are errors because it wasn’t imported see instuction.

This. The instructions in the example should be modified to reflect that the order in which you import these libraries matters. I never usually have to look in the solution but this isn’t obvious from reading the description of the code alone

I put dplyr first and I got it right, not sure what error you got.