Hello!
I have a dataset in the form:
df <- data.frame(name = c("Tom", "Henry", "Linda"),
gpa= c(3.5, 3, 3.7),
friend1_name = c("David", "Anita", "Jay"),
friend1_gpa = c(2.9, 3.8, 3.1),
friend2_name = c("", "Selena", "William"),
friend2_gpa = c(NA, 3.6, 3.5),
friend3_name = c("", "Greg", "Olivia"),
friend3_gpa = c(NA, 3.3, 3.4),
friend4_name = c("", "Helen", NA),
friend4_gpa = c(NA, 3.6, NA))
And I want it in the long-form with just variables name, gpa, friend_name and friend_gpa. Missing values can be dropped. I am struggling with the reshape function ..
Thank you so much!