R/draw_a_name.R

Defines functions draw_a_name

Documented in draw_a_name

#' Function: draw_a_name
#' This function returns the graph of the evolution of the occurence of a name over time in France
#'
#' @param the_sex sex of the person
#' @param the_name name of the person
#'
#' @return graph of the evolution of name over time
#' @export
#' @import prenoms
#' @import ggplot2
#' @import dplyr
#' @import dygraphs
#' @import tidyr
#' @import assertthat
#' @examples
#' draw_a_name(the_sex = "M", the_name = "Pierre")
#'
draw_a_name <- function(the_sex, the_name) {
  assert_that(is.character(the_sex))
  assert_that(is.character(the_name))
  prenoms::prenoms %>% filter(sex == the_sex, name == the_name) %>%
    group_by(year) %>% summarise(total=sum(n)) %>%
    ggplot( aes(x = year, y = total)) + geom_line()
}
Cyriac96/assignment documentation built on May 28, 2019, 12:18 p.m.