[R] Need to insert various rows of data from a data frame after particular rows from another dataframe
Ranjeet Kumar Jha
r@njeetjh@||tkgp @end|ng |rom gm@||@com
Wed Jul 27 08:34:41 CEST 2022
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.pikal using 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-bounces using r-project.org> On Behalf Of Ranjeet Kumar
> Jha
> > Sent: Monday, July 25, 2022 3:03 PM
> > To: R-help <r-help using 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 using 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: *ranjeetjhaiitkgp using gmail.com <ranjeetjhaiitkgp using gmail.com>*
*"Simple Heart, Humble Attitude and Surrender to Supreme Being make our
lives beautiful!"*
[[alternative HTML version deleted]]
More information about the R-help
mailing list