Hi.
„is not working“ is extremelly vague. 1. What do you expect this code do? for(cr in seq_along(dacnet_17$district)){ match(arhar_18$district, dacnet_17$district) } See ?match and maybe also ?“for“ and try this x <- letters[1:5] y <- sample(letters, 100, replace=T) match(x,y) [1] 45 16 24 13 71 for(i in 1:3) match(x,y) 2. rbind works as expeceted arhar_18 <- data.frame(a=1:10, b=50, c=letters[1:10]) dacnet_17 <- data.frame(a=11:20, b=100, c=sample(letters,10)) df3=rbind(arhar_18,dacnet_17) if your data has common column order and type. To get more specific answer you need to ask specific question preferably with some data included (most preferably by dput command) and error message. Cheers Petr From: Ranjeet Kumar Jha <ranjeetjhaiit...@gmail.com> Sent: Wednesday, July 27, 2022 8:35 AM To: PIKAL Petr <petr.pi...@precheza.cz> Cc: R-help <r-help@r-project.org> Subject: Re: [R] Need to insert various rows of data from a data frame after particular rows from another dataframe Hi Petr, I used r-bind but it's not working. Here is the code: arhar_18<-read.csv("D:/Ranjeet/IAMV6/input/yield/kharif_18-19_yield/Kharif_2018/arhar_18.csv") dacnet_17<-read.csv("D:/Ranjeet/IAMV6/input/yield/dacnet_yield_update till 2019.csv") for(cr in seq_along(dacnet_17$district)){ match(arhar_18$district, dacnet_17$district) } df3=rbind(arhar_18,dacnet_17) df3=df3[order(df3$district,df3$year),] x<-write.csv(df3,"df3.csv") view(x) On Wed, Jul 27, 2022 at 12:00 PM PIKAL Petr <petr.pi...@precheza.cz <mailto:petr.pi...@precheza.cz> > wrote: Hi. >From what you say, plain "rbind" could be used, if the columns in both sets are the same and in the same order. After that you can reorder the resulting data frame as you wish by "order". AFAIK for most functions row order in data frame does not matter. Cheers Petr > -----Original Message----- > From: R-help <r-help-boun...@r-project.org > <mailto:r-help-boun...@r-project.org> > On Behalf Of Ranjeet Kumar Jha > Sent: Monday, July 25, 2022 3:03 PM > To: R-help <r-help@r-project.org <mailto:r-help@r-project.org> > > Subject: [R] Need to insert various rows of data from a data frame after > particular rows from another dataframe > > Hello Everyone, > > I have dataset in a particular format in "dacnet_yield_update till 2019.xlsx" file, > where I need to insert the data of rows 2018-2019 and > 2019-2020 for the districts those data are available in "Kharif crops yield_18- > 19.xlsx". I need to insert these two rows of data belonging to every district, if > data is available in a later excel file, just after the particular crop group data for > the particular district. > > I have put the data file in the given link. > https://drive.google.com/drive/u/0/folders/1dNmGTI8_c9PK1QqmfIjnpbyzuiC > XgxFC > > Please help solving this problem. > > Regards and Thanks, > Ranjeet > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org <mailto: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. -- Ranjeet Kumar Jha, M.Tech. (IIT Kharagpur), Ph.D. (USA) https://www.linkedin.com/in/ranjeet-kumar-jha-ph-d-usa-73a5aa56 ----------------------------------------------------------- Email: <mailto:ranjeetjhaiit...@gmail.com> ranjeetjhaiit...@gmail.com "Simple Heart, Humble Attitude and Surrender to Supreme Being make our lives beautiful!"
______________________________________________ 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.