unite_two_DF | R Documentation |
Combine two data frames according to shared variable
unite_two_DF( data1, data1.shared.var, data1.shared.column.num = 1, data2, data2.shared.var, data2.shared.column.num = 1, delete.not.shared = FALSE, not.shared = "all", verbose = TRUE )
data1, data2 |
data frames |
data1.shared.var, data2.shared.var |
same variables in data frames |
data1.shared.column.num, data2.shared.column.num |
integer; column numbers of same variables in data frames |
delete.not.shared |
logical; delete rows that present in one data frame but do not present in other data frame |
not.shared |
character; which rows to delete; possible values are
|
verbose |
logical; show messages |
This function combines columns of two data frames according to shared.var
which acts like rows' identification number.
If shared.var
value from one data frame do not present in other data frame, NAs are produced.
Those absent rows are deleted when delete.not.shared = TRUE
.
data1.shared.var
and data2.shared.var must contain unique values within its own data frame.
Order of rows in resulting data frame is according to data1
.
data2.shared.var
is removed from resulting data frame.
Combined data frame.
Elena N. Filatova
#same values in shared variables data1 <- data.frame (N = 1:5, letter = rep("A", 5)) data2 <- data.frame (N = 1:5, letter = rep("B", 5), cs = rep("cs",5)) unite_two_DF (data1 = data1, data1.shared.var = data1$N, data2 = data2, data2.shared.var = data2$N, delete.not.shared = TRUE, not.shared = "all") #different values in shared variables data1 <- data.frame (N = 1:5, letter = rep("A", 5)) data2 <- data.frame (N = 3:8, letter = rep("B", 6), cs = rep("cs",6)) unite_two_DF (data1 = data1, data1.shared.var = data1$N, data2 = data2, data2.shared.var = data2$N) unite_two_DF (data1 = data1, data1.shared.var = data1$N, data2 = data2, data2.shared.var = data2$N, delete.not.shared = TRUE, not.shared = "data1") unite_two_DF (data1 = data1, data1.shared.var = data1$N, data2 = data2, data2.shared.var = data2$N, delete.not.shared = TRUE, not.shared = "data2") unite_two_DF (data1 = data1, data1.shared.var = data1$N, data2 = data2, data2.shared.var = data2$N, delete.not.shared = TRUE, not.shared = "all")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.