Chapter 2 RStudio Environment and Installation
first thing first: install
and library
I wish someone had used this analogy when I was learning R Studio for the very first time.
People are constantly saying “Oh you need to install this package”, and therefore I install every package every time I use R Studio.
Then people will ask you to “call the package out” using a ‘library’ function.
These two things inside R Studio confused me a lot in the beginning, (and I was mocked by a TA who was very inconsiderate of people who have never learned coding before), hopefully here you can find some answers. And I will not mock you. I swear. I know the struggles.
I now think of this as making a sandwich. Pick whatever sandwich you like. I will do a peanut butter and chocolate sandwich here.
So, imagine you will make a peanut butter and chocolate sandwich. You need ingredients. So you went to a nearby grocery store to purchase chocolate spread, peanut butter, and toast. (Feel free to switch to any other food you like, also please do not follow my recipe if you are allergic to peanuts or chocolate!)
This step (getting ingredients from a store) is called install
.
Then, you go back to your kitchen and pull these ingredients out from your reusable bag, this action is similar to the library
function.
Let’s assume these ingredients will never run out. (What a heaven!) Then, the next time you want the peanut butter and chocolate sandwich, all you need to do is pull out these ingredients again. There is no need to go back to the store every time you want it, you already have it in your kitchen!
Therefore, whenever you need to use some package you have not used before, you need to install
them first. Then afterward, the only thing you need to do is to use the library
function to pull this magical stuff out of your bag.
Okay, I hope you are still with me, and not already in the kitchen looking for your chocolate spread.