pivot_longer usage

Hi everyone!

I'm using the funtion pivot_longer instead of spread. My issue is that I want to pivot_longer 4 columns into 3 new columns (Key, Value1, Value2).

For example: I have CapBusiness, CapTourist, PaxBusiness, PaxTourist.
What I want to achieve is: Cabin, Cap, Pax.
Cabin must have just 2 values: Business and Tourist.
Cap and Pax must be the values of each one.

How can I accomplish this with pivot_longer?


To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.