• Grelot Frederic's avatar
    catnat, population, clc · 9dbbbaeb
    Grelot Frederic authored
    - catnat dataset remplace gaspar dataset
    	- passage en array pour garder les types d'aléa
    - estimate_catnat_freq incluse dans la librairie
    - population dataset pour la population
    - clc_color dataset pour les couleurs et label de clc
    - map_so_ii inclus population, gère les légendes pour les thèmes
    - dossier script hors librairie por garder la trace des mises à jour des données (doit aller dand floodam.data)
    
    0 errors :heavy_check_mark: | 0 warnings :heavy_check_mark: | 1 note :heavy_multiplication_x:
    Mais la note concerne le temps...
    9dbbbaeb
estimate_catnat_freq.R 1.17 KiB
#' @title Estimate frequency of Cat Nat events
#' 
#' @param commune factor, commune
#' @param period POSIXct, a date for the event
#' @param hazard factor, type of hazard
#' @param period_format character, format to extract information from period
#'
#' @return array fivving frequency of Cat Nat events with 3 dimensions
#'      (commune, period, hazard)
#' @export
#' @encoding UTF-8
#' @author Frédéric Grelot
#' @author David Nortes Martinez
#' 
#' @examples
#' 
#' \dontrun{
#' # To be added (soon)
#' }
estimate_catnat_freq = function(
    commune,
    period,
    hazard,
    period_format = "%Y"
) {
    period = format(as.Date(period), period_format)
    period_levels = switch(
        EXPR = period_format,
        "%Y" = formatC(
            1982:as.integer(format(Sys.Date(),"%Y")),
            width = 4, format = "d", flag = "0"
        "%m" = formatC(1:12, width = 2, format = "d", flag = "0"),
        sort(unique(as.character(period)))
    result = data.frame(
        commune = commune,
        period = factor(period, levels = period_levels),
        hazard = hazard
    result = table(result)
    class(result) = "array"
    return(result)