Tuesday, 9 June 2020

Important R packages - Part-1: Dplyr


Important R packages - Part-1

Data Manipulation

Dplyr:Dplyr is the data manipulation package that helps to solve most common data manipulation challenges

a) Mutate-Is is used to create new variable from the data

mutate(data,new_variable)
mutate(mtcars,new_var=mpg/cyl)

b) Filter- It is used to select rows based on filter applied

filter(data,variable)
filter(mtcars,gear == 4)

c) Select - It is used to pick columns as per requirement

select(data,variables)
select(mtcars,mpg,cyl,disp)

d) Summarise() - It is used to reduce multiple values to a single summary

summarise(data,Name-value pairs)
summarise(mtcars, cyl_mean=mean(cyl),cyl_median=median(cyl))


e) Arrange() - It is used to sort the data

arrange(data,variable)
arrange(mtcars,mpg)

No comments:

Post a Comment