[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
Thu Jul 28 09:34:57 CEST 2022


I tried using the merge, and join function but it is not providing in the
rows below the yield data of previous years for the same crop in the dacnet
file.

On Wed, Jul 27, 2022 at 6:04 PM Ebert,Timothy Aaron <tebert using ufl.edu> wrote:

> I think what you want is full_join() from the dplyr package.
> https://www.rdocumentation.org/packages/dplyr/versions/0.7.8/topics/join
>
> The only requirement is that both data frames must have a column in common
> wherein the data are entered in the same way. So the column labeled "state"
> needs to have "ANANTAPUR" in both data frames rather than "ANANTAPUR" in
> one data frame and "Anantapur" in the other.
>
> Reformat your excel spreadsheet to remove headers. Your first column
> should be three columns: State, then Crop, then district rather than
> headings. The first row can contain variable names. I would make variable
> names simple (like "Area" and "Production") but some like more information
> so "Area_Ha" and "Production_TN_per_Ha" would also work. It is best not to
> use special symbols in variable names and keep variable names as one string
> of characters (no spaces). Including such will eventually cause problems.
>
> https://www.w3schools.com/r/r_variables.asp#:~:text=Variable%20Names&text=Rules%20for%20R%20variables%20are,be%20followed%20by%20a%20digit
> .
>
> One exception to the rules in the link is that you can make a variable
> name T or F. R defaults to interpreting these as TRUE and FALSE. The
> problem happens when the programmer reassigns these and then tries to use T
> or F as Boolean in other parts of the program.
>
> Tim
>
> -----Original Message-----
> From: R-help <r-help-bounces using r-project.org> On Behalf Of Ranjeet Kumar Jha
> Sent: Monday, July 25, 2022 9:03 AM
> 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
>
> [External Email]
>
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__drive.google.com_drive_u_0_folders_1dNmGTI8-5Fc9PK1QqmfIjnpbyzuiCXgxFC&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=9B32l682GguXDLEFdPm6j5JZNatveGSlY7lnwLYFVOW2TX1tNLeHbDE49MYxSh_Q&s=4_bhl2_drIA0Pn3LHMcoAd02lX0t6bAx2wSlhVAJelA&e=
>
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Dhelp&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=9B32l682GguXDLEFdPm6j5JZNatveGSlY7lnwLYFVOW2TX1tNLeHbDE49MYxSh_Q&s=MAGsb78RBOWV0usgeNnmHsZcYoQI959dmihJ9Ycs8Lo&e=
> PLEASE do read the posting guide
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.R-2Dproject.org_posting-2Dguide.html&d=DwICAg&c=sJ6xIWYx-zLMB3EPkvcnVg&r=9PEhQh2kVeAsRzsn7AkP-g&m=9B32l682GguXDLEFdPm6j5JZNatveGSlY7lnwLYFVOW2TX1tNLeHbDE49MYxSh_Q&s=PSiyw67xhInkZo69l1HojQKGOqthbxYpGL5Q14cPo8w&e=
> 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