Hi, I am trying to merge columns from four different .csv files into one dataframe. I am trying to do something like this https://statisticsglobe.com/merge-csv-files-in-r . I am taking long format .csv files, 1 being the base file (testing-long.csv) which I change to wide format first and the three others being supplemental files that should add columns plight, plightLitter, Root Biomass, NO3Soil, NH4Soil and then add data to cells where the it matches any one of the values for columns, "Exp", "Year", "Field", "Plot", "NTrt", "NAdd", "NitrAdd", "NAtm.NAdd". So the values for the supplemental files need not match every single one of the columns listed above and if the value does not match all the columns exactly the cell for that column/row should not be filled. When I try the method from that website, I do not see the supplemental columns being added. I am wondering if there is a better way to merge multiple .csv files. I hope this makes sense, but it is quite confusing even to me, so I am more than happy to clarify. I am attaching the files in question.
I really think you need to create a simple reprex to show us what you want to do. In doing so, you may figure out how to get what you want. I suspect you may also need to spend some more time learning R -- following rote examples can be a fool's errand if you don't know the basics. Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Wed, Jun 9, 2021 at 3:41 PM Esthi Erickson <ericksonesthi at gmail.com> wrote:> Hi, > > I am trying to merge columns from four different .csv files into one > dataframe. I am trying to do something like this > https://statisticsglobe.com/merge-csv-files-in-r . I am taking long format > .csv files, 1 being the base file (testing-long.csv) which I change to wide > format first and the three others being supplemental files that should add > columns plight, plightLitter, Root Biomass, NO3Soil, NH4Soil and then add > data to cells where the it matches any one of the values for columns, > "Exp", "Year", "Field", "Plot", "NTrt", "NAdd", "NitrAdd", "NAtm.NAdd". So > the values for the supplemental files need not match every single one of > the columns listed above and if the value does not match all the columns > exactly the cell for that column/row should not be filled. When I try the > method from that website, I do not see the supplemental columns being > added. I am wondering if there is a better way to merge multiple .csv > files. I hope this makes sense, but it is quite confusing even to me, so I > am more than happy to clarify. I am attaching the files in question. > ______________________________________________ > R-help at 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. >[[alternative HTML version deleted]]
Attachments have been stripped by the mailing list. Read the Posting Guide. Also, English can help, but R code can be ever so much more clear in indicating what you have to work with and even what you want out of the broken/missing part of your code. https://cran.r-project.org/web/packages/reprex/index.html (read the vignette) On June 9, 2021 1:28:13 PM PDT, Esthi Erickson <ericksonesthi at gmail.com> wrote:>Hi, > >I am trying to merge columns from four different .csv files into one >dataframe. I am trying to do something like this >https://statisticsglobe.com/merge-csv-files-in-r . I am taking long >format >.csv files, 1 being the base file (testing-long.csv) which I change to >wide >format first and the three others being supplemental files that should >add >columns plight, plightLitter, Root Biomass, NO3Soil, NH4Soil and then >add >data to cells where the it matches any one of the values for columns, >"Exp", "Year", "Field", "Plot", "NTrt", "NAdd", "NitrAdd", "NAtm.NAdd". >So >the values for the supplemental files need not match every single one >of >the columns listed above and if the value does not match all the >columns >exactly the cell for that column/row should not be filled. When I try >the >method from that website, I do not see the supplemental columns being >added. I am wondering if there is a better way to merge multiple .csv >files. I hope this makes sense, but it is quite confusing even to me, >so I >am more than happy to clarify. I am attaching the files in question. >______________________________________________ >R-help at 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.-- Sent from my phone. Please excuse my brevity.