R/drawname.R

Defines functions draw_a_name

Documented in draw_a_name

#' Plot the evolution of a name given in France
#'
#' @param the_name Name to look up
#' @param the_sex Sex of the name
#'
#' @return a graphic
#' @export
#' @import ggplot2 tidyr dplyr dygraphs prenoms assertthat
#' @examples
#' \dontrun{
#' draw_a_name("Hamza","M")
#' }
#'
draw_a_name <- function(the_name,the_sex){
  assert_that(is.character(the_name))
  assert_that(the_sex %in% c("F","M"))
  base <- prenoms::prenoms %>%
    filter(name == the_name & sex == the_sex) %>%
    group_by(year) %>%
    summarize(total=sum(n))

  ggplot(data = base, aes(x = year, y = total)) +
    geom_line()
}
hamzasen/homework documentation built on May 28, 2019, 8:55 p.m.