Hi Esthi, Have you tried something like: df2<-merge(df,df1,by.x="Sample",by.y="Plot",all.y=TRUE)
This will get you a right join in "df2", not overwriting "df". Jim On Wed, Jun 30, 2021 at 1:13 AM Esthi Erickson <ericksones...@gmail.com> wrote: > > Hi and thank you in advance, > > If I have a dataframe, df: > > Sample > > Plot > > Biomass > > 1 > > 1 > > 1024 > > 1 > > 2 > > 32 > > 2 > > 3 > > 223 > > 2 > > 4 > > 456 > > 3 > > 1 > > > 3 > > 2 > > 331 > > 3 > > 3 > > 22151 > > 3 > > 4 > > 1441 > > And another one, df1: > > Sample > > Plot > > % cover of plant1 > > % cover of plant2 > > 3 > > 1 > > 32 > > 63 > > 3 > > 2 > > 3 > > > 3 > > 3 > > > 3 > > 3 > > 4 > > 5 > > 23 > > I want to join these tables where the columns Sample and Plot are the same. > > Currently trying: > > df<- right_join(df, df1, by = c(“Sample”, "Plot")) > > I am working with a much larger dataset, but it will cut off the data > starting at Sample 3 instead of joining the tables while retaining the > information from df. Any ideas how I could join them this way? > > > Esthi > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.