Hello!
I am trying to merge together row values based on a grouped column. In this example I am trying to merge the values in "Teacher", "Unit", and "Day" when the "Course.Name" equals "English". I want the "Date" column for the combined rows to be the earliest date available for "English".
Example:
Turn df into df2
df <- data.frame(Course.Name = c("English", "English", "English", "French", "Spanish"),
Teacher = c("Gonzalez", "Smith", "Johnson", "Applegate", "Lowell"),
Unit = c("A", "B", "C", "D", "E"),
Day = c("Monday", "Tuesday", "Thursday", "Wednesday", "Friday"),
Date = c("2022-01-01", "2022-01-02", "2022-02-05", "2022-03-31", "2022-02-14"))
df2 <- data.frame(Course.Name = c("English", "French", "Spanish"),
Teacher = c("Gonzalez; Smith; Johnson", "Applegate", "Lowell"),
Unit = c("A; B; C", "D", "E"),
Day = c("Monday; Tuesday; Thursday", "Wednesday", "Friday"),
Date = c("2022-01-01", "2022-03-31", "2022-02-14"))```
#I think using dplyr's `grouped_by` function along with `paste/collapse` is the way to go.
#But I can't make it work.