diff --git a/R/data.R b/R/data.R index c19cae0..bf924bf 100644 --- a/R/data.R +++ b/R/data.R @@ -1,20 +1,3 @@ -#' UNHCR data for 2017 -#' -#' The dataset contains data about UNHCR's populations of concern for the year 2017. -#' -#' @format A data frame with 11237 observations and the following 6 variables: -#' \describe{ -#' \item{\code{country_origin}}{Country of origin of population} -#' \item{\code{country_residence}}{Country / territory of asylum/residence of population} -#' \item{\code{population_type}}{Populations of concern : Refugees, Asylum-seekers, Internally displaced persons (IDPs), Returned refugees, -#' Returned IDPs, Stateless persons, Others of concern.} -#' \item{\code{value}}{Number of people concerned} -#' \item{\code{continent_residence}}{Continent of origin of population} -#' \item{\code{continent_origin}}{Continent of residence of population} -#' } -#' @source UNHCR (The UN Refugee Agency) (\url{https://www.unhcr.org/}) -"unhcr_popstats_2017" - #' UNHCR data by continent of origin #' @@ -24,7 +7,7 @@ #' \describe{ #' \item{\code{year}}{Year concerned.} #' \item{\code{population_type}}{Populations of concern : Refugees, Asylum-seekers, Internally displaced persons (IDPs), Returned refugees, -#' Returned IDPs, Stateless persons, Others of concern.} +#' Returned IDPs, Stateless persons, Others of concern.} #' \item{\code{continent_origin}}{Continent of residence of population.} #' \item{\code{n}}{Number of people concerned.} #' } @@ -40,7 +23,7 @@ #' @format A data frame with 120 observations and the following 3 variables: #' \describe{ #' \item{\code{date}}{date.} -#' \item{\code{type}}{Type of data : realized or forecast.} +#' \item{\code{type}}{Type of data : realized or forecast.} #' \item{\code{value}}{Value in giga-watt per hour.} #' } #' @source Rte (Electricity Transmission Network in France) (\url{https://data.rte-france.com/}) @@ -53,7 +36,7 @@ #' @format A data frame with 60 observations and the following 5 variables: #' \describe{ #' \item{\code{datetime}}{Timestamp.} -#' \item{\code{open}}{Open value.} +#' \item{\code{open}}{Open value.} #' \item{\code{high}}{Highest value.} #' \item{\code{low}}{Lowest value.} #' \item{\code{close}}{Close value.} @@ -63,14 +46,14 @@ #' @title Paris Climate -#' +#' #' @description Average temperature and precipitation in Paris for the period 1971-2000. #' #' #' @format A data frame with 12 observations and the following 3 variables: #' \describe{ #' \item{\code{month}}{Month} -#' \item{\code{temperature}}{Temperature (in degree celsius).} +#' \item{\code{temperature}}{Temperature (in degree celsius).} #' \item{\code{precipitation}}{Precipitation (in mm).} #' } #' @source Wikipedia (\url{https://fr.wikipedia.org/wiki/Climat_de_Paris}) diff --git a/data/unhcr_popstats_2017.rda b/data/unhcr_popstats_2017.rda deleted file mode 100644 index 4f508b2..0000000 Binary files a/data/unhcr_popstats_2017.rda and /dev/null differ diff --git a/examples/add-lines.R b/examples/add-lines.R index 734ff3b..77eec94 100644 --- a/examples/add-lines.R +++ b/examples/add-lines.R @@ -2,34 +2,38 @@ library(apexcharter) # On a column chart -apex( - data = table(unhcr_popstats_2017$continent_residence), - aes(Var1, Freq), - "column" -) %>% - add_hline(value = 2100) +unhcr_ts %>% + subset(year == 2017 & population_type == "Asylum-seekers") %>% + apex( + aes(continent_origin, n), + "column" + ) %>% + add_hline(value = 5e5) # On a scatter chart apex( - data = iris, - aes(Sepal.Length, Sepal.Width), + data = cars, + aes(speed, dist), "scatter" -) %>% - add_hline(value = mean(iris$Sepal.Width)) %>% - add_vline(value = mean(iris$Sepal.Length)) +) %>% + add_hline(value = mean(cars$dist)) %>% + add_vline(value = mean(cars$speed)) # With labels apex( - data = iris, - aes(Sepal.Length, Sepal.Width), + data = cars, + aes(speed, dist), "scatter" -) %>% +) %>% add_hline( - value = mean(iris$Sepal.Width), - label = "Mean of Sepal.Width" - ) %>% + value = mean(cars$dist), + label = "Mean of dist" + ) %>% add_vline( - value = mean(iris$Sepal.Length), - label = "Mean of Sepal.Length" + value = mean(cars$speed), + label = label( + text = "Mean of speed", + borderColor = "red" + ) ) diff --git a/man/add-vh-lines.Rd b/man/add-vh-lines.Rd index 35ed9c0..7e1ec4b 100644 --- a/man/add-vh-lines.Rd +++ b/man/add-vh-lines.Rd @@ -38,35 +38,39 @@ Add horizontal or vertical line library(apexcharter) # On a column chart -apex( - data = table(unhcr_popstats_2017$continent_residence), - aes(Var1, Freq), - "column" -) \%>\% - add_hline(value = 2100) +unhcr_ts \%>\% + subset(year == 2017 & population_type == "Asylum-seekers") \%>\% + apex( + aes(continent_origin, n), + "column" + ) \%>\% + add_hline(value = 5e5) # On a scatter chart apex( - data = iris, - aes(Sepal.Length, Sepal.Width), + data = cars, + aes(speed, dist), "scatter" -) \%>\% - add_hline(value = mean(iris$Sepal.Width)) \%>\% - add_vline(value = mean(iris$Sepal.Length)) +) \%>\% + add_hline(value = mean(cars$dist)) \%>\% + add_vline(value = mean(cars$speed)) # With labels apex( - data = iris, - aes(Sepal.Length, Sepal.Width), + data = cars, + aes(speed, dist), "scatter" -) \%>\% +) \%>\% add_hline( - value = mean(iris$Sepal.Width), - label = "Mean of Sepal.Width" - ) \%>\% + value = mean(cars$dist), + label = "Mean of dist" + ) \%>\% add_vline( - value = mean(iris$Sepal.Length), - label = "Mean of Sepal.Length" + value = mean(cars$speed), + label = label( + text = "Mean of speed", + borderColor = "red" + ) ) } diff --git a/man/unhcr_popstats_2017.Rd b/man/unhcr_popstats_2017.Rd deleted file mode 100644 index b953aba..0000000 --- a/man/unhcr_popstats_2017.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/data.R -\docType{data} -\name{unhcr_popstats_2017} -\alias{unhcr_popstats_2017} -\title{UNHCR data for 2017} -\format{ -A data frame with 11237 observations and the following 6 variables: -\describe{ -\item{\code{country_origin}}{Country of origin of population} -\item{\code{country_residence}}{Country / territory of asylum/residence of population} -\item{\code{population_type}}{Populations of concern : Refugees, Asylum-seekers, Internally displaced persons (IDPs), Returned refugees, -Returned IDPs, Stateless persons, Others of concern.} -\item{\code{value}}{Number of people concerned} -\item{\code{continent_residence}}{Continent of origin of population} -\item{\code{continent_origin}}{Continent of residence of population} -} -} -\source{ -UNHCR (The UN Refugee Agency) (\url{https://www.unhcr.org/}) -} -\usage{ -unhcr_popstats_2017 -} -\description{ -The dataset contains data about UNHCR's populations of concern for the year 2017. -} -\keyword{datasets}