0

I have a dataframe including around 2500 obs. of 500 variables. Here is the example: wide format

And here is what I want: long format

I would like to convert wide format to long format like the image above.

Is there a way to convert asset, liabilities, equality, etc. at once?

I succeeded in converting only asset to long format by referring to these sites:

http://www.cookbook-r.com/Manipulating_data/Converting_data_between_wide_and_long_format/

reshape dataframe from wide to long in R

But I don't know how to convert several variables at once.

zephryl
  • 14,633
  • 3
  • 11
  • 30
  • 2
    `df %>% tidyr::pivot_longer(!company, names_to = c("year", ".value"), names_sep = "_")`. See [Reshaping multiple sets of measurement columns (wide format) into single columns (long format)](https://stackoverflow.com/questions/12466493/reshaping-multiple-sets-of-measurement-columns-wide-format-into-single-columns) – zephryl Feb 21 '23 at 04:09
  • What about the post that you linked to didn't work? The formatting and operation are almost exactly the same – camille Feb 21 '23 at 04:30

0 Answers0