'How to make values of eeach of several factor levels into columns

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))
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source