I have two dataframes with an unique identification (variety). They differ in the following:
dat 1 is also splitted by the type, which occurs twice for each variety.
the rows of dat 1 and dat 2 are not equal - some varieties miss in dat2.
the columns by which the operation should be carried out are also not equal, i.e. taste is missing in dat1.
dat1 <- data.frame(variety = paste0("variety",rep(1:15,each=2)), type=rep(c("peanut", "regular"), 15), deliciousness = rnorm(30), aroma=rnorm(30)) dat2 <- data.frame(variety = paste0("variety",rep(1:5,each=1)), aroma=rnorm(5), taste=rnorm(5), deliciousness = rnorm(5))
What I would like to do, is adding the values from each variety of dat2 to dat1 by keeping the common columns of dat1 and dat2. Here is an example drawing on the expected operation and output:
How can this be done?
