Home > front end >  transfer rows to columns in r
transfer rows to columns in r

Time:10-24

I'm already struggling for two days just to transfer a selection of rows to a new column in r. My dataset looks like this: My starting point is "big_data". This is the data I have in a dataframe. The output should be "blub" in a dataframe. In blub the cdolumns should have names representing the value of i. data mutatie

Finally I came up with:

code I tried so many things already, but he doesn't want to give me the output as in the picture above. Is there someone who can help me whit this?

CodePudding user response:

You can use pivot_wider, from the tidyr package. For example:

library(tidyr)

blub <- pivot_wider(
data = big_data,
id_cols = id,
names_from = i,
values_from = Outstanding_LCY
)
  • Related