I have a fairly basic question here but I can't for the life of me work out why it isn't working.
I have this simple code
month = sample(1:12, 5000, replace= TRUE)
year = sample(2000:2019,5000, replace = TRUE)
loss = round(rlnorm(5000,7,2))
claim.data = cbind(month, year, loss)
head(claim.data)
max.year = aggregate(loss~year, data = claim, FUN = max)
but it is throwing up the error
Error in get(as.character(FUN), mode = "function", envir = envir) : object 'FUN' of mode 'function' was not found
which suggests that max function doesn't work. I have tried various other functions such as mean and min and they both work fine.