0

I am a newbie with R. I have a large dataset (66M obs) with pixel temperature data of 4 water bodies (REF,LMB, OTH, FP) at hourly time steps (6am,7am,8am...), with several NA values illustrating blank pixels. I want to calculate stats and indexes for each water body and time step, and I find it difficult with my current structure.

My dataframe has 3 variables: time, water, temperature. I want to have it structured as several columns representing every water body-time combination. Can you help?

I have tried mtabulate (qdapTools), but it does not work (and also it would only tabulate the water variable, and I want the combination of water and time)

DF_tab <- cbind(DF, mtabulate(DF$water))
Peter
  • 11,500
  • 5
  • 21
  • 31
RCM
  • 1
  • 2
  • post some sample data.... first read: https://stackoverflow.com/a/5963610/6356278 – Wimpel Mar 24 '22 at 10:39
  • It seems like you already have your dataset formatted as [Tidy Data](https://r4ds.had.co.nz/tidy-data.html), but you're looking to spread it out into more columns. You can do a lot of statistical analysis more easily with the Tidy Data already, but to spread out the data, you can look to using `tidyr::spread()` or `tidyr::pivot_wider()`. [More informatinon here](http://statseducation.com/Introduction-to-R/modules/tidy%20data/spread/) and [here](https://tidyr.tidyverse.org/articles/pivot.html). – chemdork123 Mar 31 '22 at 12:25

0 Answers0