CALUM POLWART
2022-Jul-27 06:22 UTC
[R] Need to insert various rows of data from a data frame after particular rows from another dataframe
Not very clear what you are trying to do. But I'd have thought possibly dplyr left_join might be a solution for you. The base R equivalent is merge(). It might be a rbind or cbind can do it too. On Wed, 27 Jul 2022, 03:30 Ranjeet Kumar Jha, <ranjeetjhaiitkgp at gmail.com> wrote:> 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_c9PK1QqmfIjnpbyzuiCXgxFC > > Please help solving this problem. > > Regards and Thanks, > Ranjeet > > [[alternative HTML version deleted]] > > ______________________________________________ > 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]]
Ranjeet Kumar Jha
2022-Jul-27 06:32 UTC
[R] Need to insert various rows of data from a data frame after particular rows from another dataframe
Hi Calum, Thanks for your reply ! Actually, I need to bring the 2018-2019 and 2019-2020 yield data corresponding to each crop in every district under a state from the "Kharif crop yield 18-19.xls" into "dacnet" file, given in the link. These two years of data from Kharif file should be brought into dacnet file after 2017 or whichever latest previous year yield that crop contains for each district in a particular state. Since Kharif file has different format and 11-12 crops with large number of districts in each state, I am unable to get the data from Kharif to dacnet into same format. So basically, kharif file yield data for 2018-2019 needs to be brought into dacnet file in the same format as it is in dacnet file. I hope it is clear now. I will really appreciate your help! Regards and Thanks, On Wed, Jul 27, 2022 at 11:52 AM CALUM POLWART <polc1410 at gmail.com> wrote:> Not very clear what you are trying to do. But I'd have thought possibly > dplyr left_join might be a solution for you. The base R equivalent is > merge(). > > It might be a rbind or cbind can do it too. > > On Wed, 27 Jul 2022, 03:30 Ranjeet Kumar Jha, <ranjeetjhaiitkgp at gmail.com> > wrote: > >> 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_c9PK1QqmfIjnpbyzuiCXgxFC >> >> Please help solving this problem. >> >> Regards and Thanks, >> Ranjeet >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> 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. >> >-- Ranjeet Kumar Jha, M.Tech. (IIT Kharagpur), Ph.D. (USA) https://www.linkedin.com/in/ranjeet-kumar-jha-ph-d-usa-73a5aa56 ----------------------------------------------------------- Email: *ranjeetjhaiitkgp at gmail.com <ranjeetjhaiitkgp at gmail.com>* *"Simple Heart, Humble Attitude and Surrender to Supreme Being make our lives beautiful!"* [[alternative HTML version deleted]]
CALUM POLWART
2022-Jul-27 06:37 UTC
[R] Need to insert various rows of data from a data frame after particular rows from another dataframe
I don't open links to random data files. Sorry. It sounds like you need to subset or filter your later data to get what you want and then merge it in. Good luck finding someone who will open a random excel sheet and then write your code for you On Wed, 27 Jul 2022, 07:32 Ranjeet Kumar Jha, <ranjeetjhaiitkgp at gmail.com> wrote:> Hi Calum, > > Thanks for your reply ! > Actually, I need to bring the 2018-2019 and 2019-2020 yield data > corresponding to each crop in every district under a state from the "Kharif > crop yield 18-19.xls" into "dacnet" file, given in the link. These two > years of data from Kharif file should be brought into dacnet file after > 2017 or whichever latest previous year yield that crop contains for each > district in a particular state. Since Kharif file has different format and > 11-12 crops with large number of districts in each state, I am unable to > get the data from Kharif to dacnet into same format. So basically, kharif > file yield data for 2018-2019 needs to be brought into dacnet file in the > same format as it is in dacnet file. > I hope it is clear now. > > I will really appreciate your help! > > > Regards and Thanks, > > On Wed, Jul 27, 2022 at 11:52 AM CALUM POLWART <polc1410 at gmail.com> wrote: > >> Not very clear what you are trying to do. But I'd have thought possibly >> dplyr left_join might be a solution for you. The base R equivalent is >> merge(). >> >> It might be a rbind or cbind can do it too. >> >> On Wed, 27 Jul 2022, 03:30 Ranjeet Kumar Jha, <ranjeetjhaiitkgp at gmail.com> >> wrote: >> >>> 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_c9PK1QqmfIjnpbyzuiCXgxFC >>> >>> Please help solving this problem. >>> >>> Regards and Thanks, >>> Ranjeet >>> >>> [[alternative HTML version deleted]] >>> >>> ______________________________________________ >>> 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. >>> >> > > -- > Ranjeet Kumar Jha, M.Tech. (IIT Kharagpur), Ph.D. (USA) > https://www.linkedin.com/in/ranjeet-kumar-jha-ph-d-usa-73a5aa56 > ----------------------------------------------------------- > Email: *ranjeetjhaiitkgp at gmail.com <ranjeetjhaiitkgp at gmail.com>* > > > *"Simple Heart, Humble Attitude and Surrender to Supreme Being make our > lives beautiful!"* > >[[alternative HTML version deleted]]