0

I'm trying to merge two dataframes (dataframe1 and dataframe2) into dataframe3. Dataframe1 has 74 observations and dataframe2 has 78 observations, 74 of which overlap. variables in dataframe1: name gender height weight variables in dataframe2: name school age income insurance I've tried many differet ways to merge (by name), but I either get a dataframe that is 0 observations and 19 variables or one that has 152 observations and 19 variables.

I've tried using merge(dataftame1,dataftame2,by=c("name"), adding all=True, rbind, using outerjoin, full join, but I always get an error or the incorrect number of observations.

The dataframe (dataftame 3) that I want would have all 78 observations, and those from dataframe1 would have missing values for variables in dataframe2, and those in dataframe2 would have missing values for variales in dataframe1. The 74 observations in both would have all variables filled in. It would be formatted like: name gender height weight name school age income insurance Name1 Name2 Name3 Name(....) Does anyone have any suggestions on how I can this output in R?

0 Answers0