STAT 218 - Week 3, Lecture 3, Lab 2
January 24th, 2024
Today we will be familiar with
ggplot()
Tip
File > New File > Quarto Document
The library()
function in R is like opening a toolbox. Imagine you have a toolbox filled with different tools, and each tool helps you do a specific job. Similarly, in R, a library is like a toolbox that contains specialized tools (packages) for specific tasks.
When you use the library()
function, you’re telling R to open a specific toolbox (load a package) so that you can access and use the tools inside.
We have two different ways to do that (within the scope of this class)
After importing our data, it is important to familiarize with our data. We have some functions to do that.
Let’s start with glimpse()
function. The name of this function is self-explanatory.
glimpse()
function gives us a brief information about out data set. We have 6 variables and 180 cases or observations.
Alternatively, we can ask R the number of columns (variables) and rows (cases) as following:
[1] 6
[1] 180
Assume that I would like to see just the names of the variables in my data set. I can use name()
function for this.
We can calculate measures of central tendency by using these unsurprising functions.
Alternatively, you can use summarize()
function for the same calculation.
Alternatively, you can use summarize()
function.
Let’s plot a simple bar chart. Next session, we will explore other features for ggplot()
.