I have two data frames:
x <- structure(list(Cluster1 = c(53L, NA, NA), Cluster10 = c(48L,
46L, NA), Cluster11 = c(2L, NA, NA)), row.names = c("Cluster1",
"Cluster10", "Cluster11"), class = "data.frame")
y <- tructure(list(Cluster1 = c(53L, NA), Cluster10 = c(46L, NA),
Cluster11 = c(2L, NA)), row.names = c("Cluster1", "Cluster11"
), class = "data.frame")
It looks like this:
> x
Cluster1 Cluster10 Cluster11
Cluster1 53 48 2
Cluster10 NA 46 NA
Cluster11 NA NA NA
> y
Cluster1 Cluster10 Cluster11
Cluster1 53 46 2
Cluster11 NA NA NA
Now, y
miss a row in x
that is Cluster10
. How can I insert that missing row and fill it with value NAs.
The final desired output for y
is:
Cluster1 Cluster10 Cluster11
Cluster1 53 48 2
Cluster10 NA NA NA
Cluster11 NA NA NA