0

I try to pivot data in a dataframe, below code works for small dataframe, however for a bigger one (80k rows) it's just running seamingly forever.

reshape(SumData,direction = "wide",idvar = c("location","lat","lon","year"), timevar = "variable")

("variable" column has just two values if that matters)

Is there a more efficient way for this?

Máté Juhász
  • 2,197
  • 1
  • 19
  • 40
  • 1
    It depends if you want to stick with `base` R or move to `tidyr` (see [here](https://tidyr.tidyverse.org/)) and `data.table` (see [here](https://cran.r-project.org/web/packages/data.table/vignettes/datatable-reshape.html) for reshaping data). Out of the 2 options, `data.table` should have much higher performance. – rps1227 Feb 10 '21 at 15:31
  • 1
    Efficient package methods might also have their limits, consider my question on [what-methods-can-we-use-to-reshape-very-large-data-sets](https://stackoverflow.com/q/55077668/6574038) – jay.sf Feb 10 '21 at 16:38

0 Answers0