Skip to main content
Alpha
This lesson is in the alpha phase, which means that it has been taught once and lesson authors are iterating on feedback.
Introduction to R
- Navigate round RStudio and create an
Rproj file.
- Use RStudio to write and run R programs.
- Install packages using the Packages tab or the
install.packages() command.
- Assign values to object using the assignment operator <-. Remove
existing objects using the
rm() function.
- Add comments in R scripts using the
# operator.
- Define and use R functions and arguments.
- Getting help with the
?, ?? and
help() functions.
- Define the following terms as they relate to R: object, vector,
assign, call, function.
- Create or add new objects to a vector using the c() function. Subset
vectors using
[].
- Deal with missing data in vectors using the is.na(), na.omit(), and
complete.cases() functions.
- Use
getwd() and setwd() to navigate
between directories.
- Use
read_csv() from tidyverse to read tabular data into
R.
- Data frames are made up of vectors of equal length, with each vector
representing each column of the data frame.
- Summarise the dimension, content and variables in a data frame.
- Using the square brackets
[] and logical operators to
subset data frames.
-
ggplot2 is a flexible and useful tool for creating
plots in R.
- The data set and coordinate system can be defined using the
ggplot function.
- Additional layers, including geoms, are added using the
+ operator.
- Boxplots are useful for visualizing the distribution of a continuous
variable.
- Barplot are useful for visualizing categorical data.
- Faceting allows you to generate multiple plots based on a
categorical variable.
-
Quarto allows you to mix code and text to create
reproducible reports.
- Use the YAML header to configure document metadata
like title and output format.
-
Code chunks run R code and can display or hide
input/output using options like
#| echo: false.
-
Rendering the document executes the code and
produces the final output (HTML, PDF, etc.).
- This workflow saves time and reduces errors when reporting on data
that changes over time.