1/54
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
What does <- do in R?
assigns the value on the right to the object name on the left
What is a data frame
table with rows and columns
What is a function in R
a command that takes inputs and returns an output
What is a code chunk in a Quarto .qmd file
a block where you write R code that Quarto runs when rendering, and it shows the results (numbers/tables/plots) in the output.
What does Render do in Quarto?
runs all code chunks and converts the .qmd into an output document (e.g., HTML/PDF) with the results inserted
What is a package in R?
a collection of functions, data, and documentation that extends the basic capabilites of R
How business decision-making has evolved
Gut instinct (hippo era)
Simple data support
Advanced analytics
Experimentation and causal learning
Types of business analytics
Descriptive
predictive
causual/prescriptive
What does ```{r} mean in Quarto?
starts an R code chunk
What does #| eval: false do?
tells Quarto not to run this code chunk when rendering
What does library(readr) do?
It loads the readr package so you can use functions from it (including read_csv())
What does class() do
Tells you what type of object something is
Use it as quick sanity check right after importing data, to confirm R read it in the way you expected.
What does names() do
Lists the column/variable names of a data frame
What does head() do
hows just the first few rows of a data frame (6 rows, by default)
preview your data without flooding the screen, handy for datasets with hundreds or thousands of rows
nrow()
Counts how many rows a data frame has
ncol()
Counts how many columns a data frame has
any()
Checks a condition across a whole column of values and returns a single TRUE if at least one value meets it, or FALSE if none do
sum()
dds up every value in a numeric column to give a single total.
ggplot()
Starts a new plot and tells R which dataset to build it from
aes()
Maps columns in your data to visual features of the plot
labs()
Adds or changes the text labels on a plot, such as the axis titles and the main title.
bins
how many bins to split the data into (for histogram)
facet_wrap()
Splits one plot into a grid of smaller plots, one panel per category.
geom_point()
Draws a scatter plot, one dot for every row of data
geom_smooth()
Adds a fitted trend line through your data.
method
the type of line to fit for trendline, for example "lm" for a straight regression line.
se
whether to show a shaded confidence band around the trendline. Set to FALSE to hide it.
alpha
the clarity of the points on scatter plot
scale_x_continuous()
Controls how the x-axis of a plot is drawn
trans
a transformation to apply to the axis, for example "log10"
labels
how to format the axis numbers, for example
scale_fill_okabe_ito()
Applies a colorblind-friendly set of colors to whatever is mapped to fill in your plot
theme_bw()
Switches the plot to a clean black-and-white theme
fct_infreq()
Reorders the categories of a variable by how often they occur, from most common to least common
after_stat()
Lets you use a value that ggplot2 calculates internally while it builds the plot, such as a count, in a further calculation of your own
dplyr
A package for wrangling data
filter()
Keeps only the rows that meet a condition you set, and drops the rest
mutate()
Creates a new column in your data, or changes an existing one, based on a calculation you specify
Build new variables
select()
Keeps only the columns you name, and drops the rest.
arrange()
Sorts the rows of your data by one or more columns
slice_max()
Keeps only the rows with the highest values of a column you choose
group_by()
Splits your data into groups based on the values of one or more columns, without changing what the data looks like on screen.
summarise()
Collapses many rows into a single summary row, using calculations you choose, such as an average
slice_head()
Shows the first few rows of your data, in the order they currently appear
n()
Counts how many rows are in the current group
desc()
Flags a column so that arrange() sorts it from highest to lowest instead of lowest to highest.
pivot_longer()
lengthen “short and wide” datasets by stacking values into a single column
pivot_wider()
shorten “long and narrow” datasets by spreading values into multiple columns
What makes data tidy?
Every tidy dataset has the same structure
Makes common R operations easier
!is.na
Checks for values that are not missing
$
Selects 1 variable in a dataset
==
boolean: ensures values on left = values on right
c()
combines arguments into a vector
!
The not operator