Investigating your data in R- Studio / Posit Cloud
You should have a R project set up and your data uploaded at this point 😊
For the purposes of explaining, there are 3 packages I’ll explain how to install and
run, and like before the data set I will be using to explain is nicknamed bird.
Don’t forget that R doesn’t like spaces and is case sensitive!
Now you have your data uploaded into your files folder, we are going to go back to
your first panel and input 6 lines of code that are going to install and run 3 packages.
You will input and run the following:
install.packages(“ggplot2”)
Once you run this, your panel 2 should show lines of red text – this is completely
fine, it is installing the package. You then need to input:
library(ggplot2)
Running this will just show you the same text repeated in your second panel, but it
has enabled R to load the package, meaning you are now able to use it.
You should now repeat this with the packages “tidyverse” and “patchwork”, this is
done in the same way as the ggplot2 package. Once you’ve installed and run these
two packages, you should have six lines of code that look like this:
install.packages(“ggplot2”)
library(ggplot2)
install.packages(“tidyverse”)
library(tidyverse)
install.packages(“patchwork”)
library(patchwork)
Now, unless you have already done so, you need to tell R to read your data. To do
this, I always make sure I have files open in my panel 4 to make sure I do not
misspell the name of my uploaded document. I also suggest you give your data set a
one-word nickname that is relevant to the data. To explain it here, I will be using data
named bird_feeder.csv and will nickname it bird.
To tell R to read your data you need to input the following code (obviously changing
where it says bird and bird_feeder to the relevant things):
bird<-read.csv(“data/bird_feeder.csv”)