• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: How to pivot a dataframe using dplyr

Resolved: How to pivot a dataframe using dplyr

0
By Isaac Tonny on 16/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve How to pivot a dataframe using dplyr

Question:

I’m trying to pivot this dataframe without success:
I need to have the apqual as columns such that all the other values of the other columns referred to the same COD_REG lie on a single row ( in my dataset you can notice that they are distributed on 2 rows)
I mean this
I’ve tried different pivot_longer, but it seems I’m not able to set it correctly. Can anyone help me?

Best Answer:

Since you’re increasing the number of columns, you want to pivot_wider:
You can select all the columns to spread by name, as above, or use other tidyverse methods to specify the columns. Both of the below functions will return the same thing:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

dataframe dplyr pivot pivot-table r
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: what are the permissions required to assign a resource monitor to a warehouse?

01/04/2023

Resolved: How can I modify formData before sending it?

01/04/2023

Resolved: How to efficient create SimpleITK image?

01/04/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.