R vectors, data frames, factors, apply family, tidyverse verbs with dplyr and ggplot2 grammar of graphics.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What does c() do in R?
Show answer
Combines values into a vector
- How do you get the length of a vector?
Show answer
Use length()
- What does rep(3, 5) create?
Show answer
A vector with 3 repeated 5 times
- What does seq(1, 10, by=2) create?
Show answer
A sequence from 1 to 10 incrementing by 2
- How do you access the third element of vector x?
Show answer
x[3]
- What are the four main vector types in R?
Show answer
numeric, character, logical, complex
- What does as.numeric('42') do?
Show answer
Converts the string to the number 42
- What is the purpose of is.numeric()?
Show answer
Tests whether an object is numeric, returning TRUE or FALSE
- How do you create a data frame in R?
Show answer
Use data.frame() function
- What does nrow(df) return?
Show answer
The number of rows in data frame df
- What does ncol(df) return?
Show answer
The number of columns in data frame df
- How do you access the column named 'age' from df?
Show answer
df$age or df[['age']]
- What does head(df) show by default?
Show answer
The first 6 rows of df
- What does tail(df, 10) show?
Show answer
The last 10 rows of df
- How do you add a new column to df?
Show answer
df$newcol <- values or df[['newcol']] <- values