I am trying to merge 2 columns within the same dataset in order to condense the number of columns.
The dataset currently looks like this:
I am trying to merge 2 columns within the same dataset in order to condense the number of columns.
The dataset currently looks like this:
Year Var1 Var2
2014 123 123
2014 NA 155
2015 541 NA
2015 432 432
2016 NA 124
I wish the dataset to look like
Year Var1.2
2014 123
2014 155
2015 541
2015 432
2016 124
I tried this code:
df$Var1.2 <- paste(df$Var1,df$Var2)
But I can this:
Year Var1.2
2014 123 123
2014 NA 155
2015 541 NA
2015 432 432
2016 NA 124
Somewhere had a suggestion?