Hello,
I have an xts file with 6000 collumns and 2000 rows, containing daily max temperatures for 6000 different places and I try to calculate the percentage of days on each one when the temperature is above the 95th percentile.
My initial thought was to calculate the 95th quantile for each one of them however when I use the quantile function, it doesnt work for each collumn seperately. Moreover unfortunetely it doesnt provide me the percentage of days, only the numeric value
This is definitely do-able. Are you able to create a reproducible example (called reprex)? This would include a snippet of data that can be copy-and-pasted so users may provide working solutions.
Hi. I am curious why you want to achieve these calculatons. By definition, the percentage of days above the 95th quantile is 5%...
Any way, a much simpler and faster way could be the following
Data <- data.frame(a = runif(100), b = rnorm(100), c = rexp(100))
qproc <- function(Data){
return(mean(Data > quantile(Data, .95)))
}
sapply(Data, qproc)
a b c
0.05 0.05 0.05
Probably I wasnt very specific on the title, I try to create a map showing the magnitude of certain extreme climate indices throughout the country, in that case the tx95 one. Because of the nature of those indices, the percentage above the 95th quantile isnt equal to 5%.
Eventually the resulting maps eventually look like this one