R/draw_a_name.R

Defines functions draw_a_name

Documented in draw_a_name

#' Drwas the timers series of a certain name of a certain sex
#'
#' @param the_name the name that is going to be plot
#' @param the_sex  the specified sex for the name being plotted
#' @import ggplot2
#' @import assertthat
#' @import prenoms
#' @import dplyr
#' @return the time series of the name and sex
#' @export
#'
#' @examples
#' dontrun {draw_a_name(c("Marie", "F"))}
draw_a_name <- function(the_name,the_sex)
{
  assert_that(is.character(the_name))
  assert_that(is.character(the_sex))
  assert_that(not_empty(prenoms::prenoms %>% filter(sex==the_sex, name==the_name )))
  Results<-prenoms::prenoms %>% filter( sex==the_sex, name==the_name ) %>% group_by(year) %>% summarise(total=sum(n))
  return(ggplot(Results, aes(year, total)) + geom_line())
}
mariafcadena/HomeworkCADENA documentation built on May 29, 2019, 3:44 a.m.