Perhaps an easy question, but I am a beginner and I could not find answers that apply to my case on stack overflow here.
I merged two datasets, which now look like this (the actual dataset has 5,000+ observations):
> data <- structure(list(Country = c("France", "France", "France", "Germany",
"Germany", "Germany"), Type_a = c("Type_a", "", "Type_a", "Type_a,Type_b",
"Type_b,Type_c,Type_f", "Type_f"), Type_b = c("", "Type_b", "Type_b",
"", "", ""), Type_c = c("", "", "Type_c", "", "", ""), Type_d = c("",
"Type_d", "", "", "", ""), Type_e = c("Type_e", "", "Type_e",
"", "", ""), Type_f = c("Type_f", "", "Type_f", "", "", "")), row.names = c(NA,
6L), class = "data.frame")
> View(data)
Please run View(data)
. Observations for France are in the right columns, but observations for Germany are all in one single column.
I want to split Germany data and assign them to the right columns, while taking into account missing data. That is, data cannot just be split and assigned to all next columns (as in the stack overflow link above), but only to select columns. Also, I do not want to create new columns.
How do I do this?
Thank you.