Code Cheatsheets
Quick references for common R tasks.Data Loading
Reading & Inspecting Data
r
data <- read.csv("mydata.csv")
head(data)
tail(data)
str(data)
summary(data)Regression
Linear Regression
r
model <- lm(y ~ x1 + x2 + x3, data = mydata)
summary(model)
coef(model)
summary(model)$r.squared
predict(model, newdata = test_data)Visualization
Basic Plots
r
plot(x, y)
hist(x)
boxplot(y ~ group, data = mydata)
plot(x, y)
abline(model, col = "red")âšī¸
Help
Use ?function_name in R to open documentation. Example: ?lm.