I have ended up with rows that have NAs that correspond to a column that was deleted and I want to get rid of those NAs. This would turn the example df below from three rows to one row and leave me one set of variables for each group.
df <- data.frame(group = c("a", "a", "a"), var1 = c(1, NA, NA), var2 = c(NA, 4, NA), var3 = c(NA, NA,
2), var4 = c(1, NA, NA), var5 = c(NA, 4, NA), var6 = c(NA, NA, 2), var7 = c(1, NA, NA),
var8 = c(NA, 4, NA), var3 = c(NA, NA, 2))
I know how to get rid of whole rows with NAs or columns with NAs, but am not sure how to collapse this.