That helps; thank you.
I think I understand now what you mean about putting NA in the fields that are missing. Dataset1 contains two variables ASAT and Billirrubine which are not present in Dataset2. Likewise, Dataset2 contains an extra variable Creatinine.
In this case, you could simply append the two data frames with bind_rows(). That will fill NA values for the missing fields.
library(dplyr, warn.conflicts = FALSE)
#> Warning: package 'dplyr' was built under R version 3.6.3
Dataset1 <- structure(
list(
Name = c("JUAN", "JUAN", "JUAN"),
Sex = c("M", "M", "M"),
ALAT = c(15, 36, 243),
ASAT = c(864, 4, 25),
Bilirrubine = c(35, 35, 62),
Alpha = c(7, 447, 34)),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -3L)
)
Dataset2 <- structure(
list(
Name = c("MARIA", "MARIA", "MARIA"),
Sex = c("F", "F", "F"),
ALAT = c(62, 47, 9654),
Creatinine = c(26, 2, 63)),
class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -3L))
bind_rows(Dataset1, Dataset2)
#> # A tibble: 6 x 7
#> Name Sex ALAT ASAT Bilirrubine Alpha Creatinine
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 JUAN M 15 864 35 7 NA
#> 2 JUAN M 36 4 35 447 NA
#> 3 JUAN M 243 25 62 34 NA
#> 4 MARIA F 62 NA NA NA 26
#> 5 MARIA F 47 NA NA NA 2
#> 6 MARIA F 9654 NA NA NA 63
Created on 2020-03-19 by the reprex package (v0.3.0)
Is this what you are trying to achieve?