I have a massive dataset of rainfall with 1048575 rows and four columns (time, lat, long, rainfall in mm). The dataset contains daily rainfall for 20 years for each unique lat-long combination (a total of 81 such lat-long combinations). I want to calculate the mean rainfall of 20 years for each unique lat-long combination.
I am new to R, Can anybody help me with the code in R?
I am giving the code I have prepared and a glimpse of the dataset
library(dplyr)
data <-read.csv('IMD_Precip.csv')
data$rain[data$rain==-999]<-NA
data_latlon <-data.frame(Lat =data$lat,
Long = data$lon,
PlotCode = data$rain,
date=as.POSIXct(data$time, "%Y %m %d"))
data_latlon %>%
group_by(date, Lat, Long) %>%
mean(PlotCodeGrouped =paste(PlotCode, date, collapse = ''))