dplyr Package in R | Introduction, Tutorial & Programming Examples | Data Manipulation in RStudio

Introduction to the dplyr package of the R programming language. More information: https://statisticsglobe.com/dplyr-r-package
R code of this video:

data <- data.frame(x1 = 1:6, # Create example data
x2 = c(1, 2, 2, 3, 1, 2),
x3 = c(“F”, “B”, “C”, “E”, “A”, “D”))
data # Print example data

install.packages(“dplyr”) # Install dplyr package
library(“dplyr”) # Load dplyr package

arrange(data, x3) # Apply arrange function

filter(data, x2 == 2) # Apply filter function

mutate(data, x4 = x1 + x2) # Apply mutate function

pull(data, x2) # Apply pull function

rename(data, new_name = x3) # Apply rename function

set.seed(765) # Set seed for reproducibility
sample_n(data, 3) # Apply sample_n function

select(data, c(x2, x3)) # Apply select function

Post Author: hatefull