Hi
I want to merge one secondary df into my core df and preserve the format of my core df, creating a new column where the data for each observation is separated by a comma, and leaving blank cells in the new column for observations of the core df that don't appear in the secondary one
ie.
# core data set
obs_names <- c("county 1", "county 2", "county 3", "county 4")
col1 <- c("value 1", "value 2", "value 3", "value 4")
df1 <- data.frame(obs_names, col1)
#secondary data set
obs_names <- c("area 1", "area 2", "area 3")
col1 <- c("county 1", "county 2", "county 1")
df2 <- data.frame(obs_names, col1)
how can I merge to create something like:
New Dataset
names col1 col2
county 1 value 1 area 1, area 3
county 2 value 2 area 2
county 3 value 3
county 4 value 4