0 XP
R Editor
R-bae AI
Console Output
Press Run Code to see output
Basics
print(x)
Print value to console
x <- 5
Assign value to variable
class(x)
Check data type
length(x)
Number of elements
c(1, 2, 3)
Create a vector
1:10
Sequence from 1 to 10
Data Frames
data.frame()
Create a data frame
df$column
Access a column
nrow(df)
Number of rows
ncol(df)
Number of columns
head(df)
First 6 rows
str(df)
Structure overview
Statistics
mean(x)
Average
median(x)
Middle value
sd(x)
Standard deviation
sum(x)
Sum of values
min(x) / max(x)
Min and max
summary(x)
Statistical summary
dplyr (tidyverse)
filter(df, cond)
Filter rows
select(df, cols)
Choose columns
mutate(df, new=...)
Add/transform columns
arrange(df, col)
Sort rows
group_by(df, col)
Group data
summarise(df, ...)
Aggregate groups
Great work!