Hey guys, I am very new to R and need some assistance. I have a big data set with numerous variables. I have attached an example below
Age <- c(24, 24, 24)
Name <- c('Pete', 'Pete', 'Pete')
City <- c('PHI', 'MIN', 'TOT')
dat <- data.frame(Age, Name, City)
dat
I am wondering how to combine the rows together so it looks something like this with the cities all in the same cell, and being only one observation rather than 3.
Age <- c(24)
Name <- c('Pete')
City <- c('PHI, MIN, TOT')
dat2 <- data.frame(Age, Name, City)
dat2
The data has a few cases of double ups like this, but not all of it is double ups, so I am wondering if there is possibly a script to run through the whole data set and combine it as such, rather than pulling out each case individually, running this data and then putting it back into the dataset?
Any help will be greatly appreciated!
Thanks