Categories

Nov 6, 2019 in R Language

Q: Four important functions used in dplyr to merge two datasets.

1 Answer

Nov 6, 2019
Function Objectives Arguments Multiple keys
left_join() Merge two datasets. Keep all observations from the origin table data, origin, destination, by = "ID" origin, destination, by = c("ID", "ID2")
right_join() Merge two datasets. Keep all observations from the destination table data, origin, destination, by = "ID" origin, destination, by = c("ID", "ID2")
inner_join() Merge two datasets. Excludes all unmatched rows data, origin, destination, by = "ID" origin, destination, by = c("ID", "ID2")
full_join() Merge two datasets. Keeps all observations data, origin, destination, by = "ID" origin, destination, by = c("ID", "ID2")

Using the tidyr Library you can transform a dataset with the gather(), spread(), separate() and unit() functions.

Function

Objectives

Arguments

gather()

Transform the data from wide to long

(data, key, value, na.rm = FALSE)

spread()

Transform the data from long to wide

(data, key, value)

separate()

Split one variables into two

(data, col, into, sep= "", remove = TRUE)

unit()

Unit two variables into one

(data, col, conc ,sep= "", remove = TRUE)

Click here to read more about Loan/Mortgage
Click here to read more about Insurance

Related questions

Madanswer
Jul 28, 2019 in R Language
Nov 6, 2019 in R Language
Jul 28, 2019 in R Language
...