| Type: | Package |
| Title: | Easy Estimation and Vizualisation of Indicators from Data with Complex Design |
| Version: | 0.5.1 |
| Description: | Many functions to easily vizualise and estimate indicators such as proportions, means, medians and continuous/discrete distributions from complex survey data. The package also estimates confidence intervals for all indicators, compares different groups and computes different statistical tests. |
| License: | GPL-3 |
| URL: | https://jgires.github.io/fonctionr/, https://github.com/jgires/fonctionr/ |
| BugReports: | https://github.com/jgires/fonctionr/issues |
| Depends: | R (≥ 4.1.0) |
| Imports: | doParallel, dplyr, forcats, foreach, ggnewscale, ggplot2, ggtext, grDevices, rlang, scales, showtext, srvyr, stringr, survey, sysfonts, tibble, tidyr |
| Suggests: | broom, colorspace, knitr, kableExtra, laeken, MetBrewer, openxlsx, patchwork, PrettyCols, rmarkdown |
| VignetteBuilder: | knitr |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | no |
| Packaged: | 2026-03-21 12:40:34 UTC; 00104504 |
| Author: | Joel Gires [aut, cre, cph], Francois Ghesquiere [aut] |
| Maintainer: | Joel Gires <joel.gires@vivalis.brussels> |
| Repository: | CRAN |
| Date/Publication: | 2026-03-25 21:00:16 UTC |
central_group
Description
Function to compare means or medians among different groups based on complex survey data. It produces a list containing a table, including the confidence intervals of the indicators, a ready-to-be published ggplot graphic and a statistical test.
In case of mean comparison, the statistical test is a Wald test (using survey::regTermTest()). In case of median comparison the statistical test is a Kruskal Wallis test (using survey::svyranktest()). The confidence intervals and the statistical test are taking into account the complex survey design. In case of facets, the statistical test is computed on the total means or medians between facets (and not within facets). In case of second group (group.fill), no statistical test is computed.
Exporting the results to an Excell file is possible.
Usage
central_group(
data,
group,
quanti_exp,
type,
group.fill = NULL,
facet = NULL,
filter_exp = NULL,
...,
na.rm.group = TRUE,
na.rm.facet = TRUE,
total = TRUE,
reorder = FALSE,
show_ci = TRUE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
total_name = NULL,
digits = 0,
unit = "",
dec = NULL,
col = NULL,
pal = "OBSS_Spring",
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
wrap_width_leg = 25,
legend_ncol = 4,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
legend_lab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
median_group(..., type = "median")
mean_group(..., type = "mean")
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
group |
A variable defining groups to be compared. |
quanti_exp |
An expression defining the quantitative variable from which the mean/median is computed. Notice that if any observations with |
type |
|
group.fill |
A variable defining a second variable of groups to be compared. |
facet |
A variable defining the faceting group. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.group |
|
na.rm.facet |
|
total |
|
reorder |
|
show_ci |
|
show_n |
|
show_value |
|
show_labs |
|
total_name |
Name of the total displayed on the graphic. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is none ( |
dec |
Decimal mark displayed on the graphic. Default depends on lang: |
col |
Color of the bars if there is no |
pal |
Colors of the bars if there is a |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. Value shoud be ranged between |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. Value shoud be ranged between |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of the groups. Default is |
wrap_width_leg |
Number of characters before going to the line for the labels of the |
legend_ncol |
Number of columns in the legend. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
legend_lab |
Legend (fill) label on the graphic. If |
caption |
Caption of the graphic. This caption goes under de default caption showing the result of the statistical test. There is no way of not showing the result of the chi-square test as a caption. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes three (without |
Value
A list that contains a table, a ggplot graphic and, in most cases, a statistical test.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Creation of age categories
eusilc$age_cat <- cut(eusilc$age,
breaks = 6,
include.lowest = TRUE)
# Calculation of income means by age category with fonctionr, taking sample design into account
eusilc_mean <- mean_group(
eusilc,
group = age_cat,
quanti_exp = eqIncome / 12,
strata = db040,
ids = db030,
weight = rb050,
title = "Mean of equivalised income in household by age of individuals",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_mean$graph
# Results in table format
eusilc_mean$tab
distrib_continuous
Description
Function to describe the distribution of a continuous variable from complex survey data. It produces a list containing a density table (dens), a central value table (tab), a quantile table (quant) and a ready-to-be published ggplot graphic (graph).
The density table contains x-y coordinates to draw a density curve. The central value table contains the median or the mean of the continuous variable, with its confidence interval, the sample size and the estimation of the total, with its confidence interval. The quantile table contains quantiles and their confidence intervals. The quantiles and the limits are used as thicks on the X axe of the graphic. The confidence intervals are taking into account the complex survey design.
Exporting those results to an Excell file is possible.
Usage
distrib_continuous(
data,
quanti_exp,
type = "median",
facet = NULL,
filter_exp = NULL,
...,
na.rm.facet = TRUE,
quantiles = seq(0.1, 0.9, 0.1),
bw = 1,
resolution = 1024,
limits = NULL,
show_mid_line = TRUE,
show_ci_lines = TRUE,
show_ci_area = FALSE,
show_quant_lines = FALSE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
digits = 0,
unit = "",
dec = NULL,
pal = NULL,
col_density = c("#00708C", "mediumturquoise"),
color = NULL,
col_border = NA,
font = "Roboto",
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
distrib_c(...)
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
quanti_exp |
An expression defining the quantitatie variable the variable to be described. Notice that any observations with |
type |
Type of central value : |
facet |
Not yet implemented. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.facet |
Not yet implemented. |
quantiles |
Quantiles computed. Default are deciles. |
bw |
The smoothing bandwidth to be used. The kernels are scaled such that this is the standard deviation of the smoothing kernel. Default is |
resolution |
Resolution of the density curve. Default is |
limits |
Limits of the X axe of the graphic. Does not apply to the computation of indicators (median/mean and quantiles). Default is |
show_mid_line |
|
show_ci_lines |
|
show_ci_area |
|
show_quant_lines |
|
show_n |
|
show_value |
|
show_labs |
|
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is none ( |
dec |
Decimal mark shown on the graphic. Depends on lang: |
pal |
For compatibility with older versions. |
col_density |
Color of the density area. It may be one color or a vector with several colors. Colors should be R color or an hexadecimal color code. In case of one color, the density is monocolor. In case of a vector, the quantile areas are painted in continuous colors going from the last color in the vector (center quantile) to the first color (first and last quantiles). In case of an even quantile area numbers (e.g. deciles, quartiles) the last color of the vector is only applied to the highcenter quantile area to avoid two continuous quantile areas having the same color. |
color |
Not currently used except for compatibility with old versions. |
col_border |
Color of the density line. Color should be one R color or one hexadecimal color code. Default ( |
font |
Font used in the graphic. See |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. If |
ylab |
Y label on the graphic. If |
caption |
Caption of the graphic. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes four sheets: the central value table, the quantile table, the density table and the graphic. |
Value
A list that contains a density table (dens), a central value table (tab), a quantile table (quant) and a ggplot graphic (graph).
Examples
# Loading of data
data(eusilc, package = "laeken")
# Computation, taking sample design into account
eusilc_dist_c <- distrib_c(
eusilc,
quanti_exp = eqIncome,
strata = db040,
ids = db030,
weight = rb050,
limits = c(0, 50000),
title = "Distribution of eq. income",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_dist_c$graph
# Results in table format
eusilc_dist_c$tab
distrib_discrete
Description
Function to describe the distribution of a discrete variable from complex survey data.
It produces a list containing a table, including the confidence intervals of the indicators, a ready-to-be published ggplot graphic and, if proportions for H0 are specified, a Chi-Square statistical test (using survey::svygofchisq()). The confidence intervals and the statistical test are taking into account the complex survey design. In case of facets, no statistical test is (yet) computed.
Exporting those results to an Excell file is possible.
Usage
distrib_discrete(
data,
quali_var,
facet = NULL,
filter_exp = NULL,
...,
na.rm.facet = TRUE,
na.rm.var = TRUE,
probs = NULL,
prop_method = "beta",
reorder = FALSE,
show_ci = TRUE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
scale = 100,
digits = 0,
unit = "%",
dec = NULL,
col = "sienna2",
pal = NULL,
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
distrib_d(...)
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
quali_var |
The discrete variable to be described. |
facet |
A variable defining the faceting group. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.facet |
|
na.rm.var |
|
probs |
Vector of probabilities for H0 of the statistical test, in the correct order (will be rescaled to sum to 1). If |
prop_method |
Type of proportion method used to compute confidence intervals. See |
reorder |
|
show_ci |
|
show_n |
|
show_value |
|
show_labs |
|
scale |
Denominator of the proportion. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is |
dec |
Decimal mark displayed on the graphic. Default depends on lang: |
col |
Color of the bars. col must be a R color or an hexadecimal color code. Default is |
pal |
Argument kept for compatibility with old versions. |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of the categories. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
caption |
Caption of the graphic. This caption goes under de default caption showing the result of the statistical test (if any). |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes two or three sheets : the table, the graphic and the statistical test (if |
Value
A list that contains a table, a ggplot graphic and, if probs is not NULL, a statistical test.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding eusilc$pl030 into eusilc$pl030_rec
eusilc$pl030_rec <- NA
eusilc$pl030_rec[eusilc$pl030 == "1"] <- "Working full time"
eusilc$pl030_rec[eusilc$pl030 == "2"] <- "Working part time"
eusilc$pl030_rec[eusilc$pl030 == "3"] <- "Unemployed"
eusilc$pl030_rec[eusilc$pl030 == "4"] <- "Student"
eusilc$pl030_rec[eusilc$pl030 == "5"] <- "Retired"
eusilc$pl030_rec[eusilc$pl030 == "6"] <- "Permanently disabled"
eusilc$pl030_rec[eusilc$pl030 == "7"] <- "Fulfilling domestic tasks"
# Computation, taking sample design into account
eusilc_dist_group_d <- distrib_d(
eusilc,
pl030_rec,
strata = db040,
ids = db030,
weight = rb050,
title = "Distribution of socio-economic status",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_dist_group_d$graph
# Results in table format
eusilc_dist_group_d$tab
distrib_group_continuous
Description
Function to compare the distribution of a continuous variable between groups from complex survey data. It produces a list containing a density table (dens), a central value table (tab), a quantile table (quant), a ready-to-be published ggplot graphic (graph), a box-plot table (moustache) and a statistical test (test).
The density table contains x-y coordinates to draw density curve for each group. The central value table contains, for each group, the median or the mean of the continuous variable, with their confidence intervals, the sample size and the estimations of the totals, with their confidence intervals. The quantile table contains, for each group, quantiles and their confidence intervals. The box-plot table contains the X coordinates to draw the moustache, for each group.
In case of mean comparison, the statistical test is a Wald test (using survey::regTermTest()). In case of median comparison the statistical test is a Kruskal Wallis test (using survey::svyranktest()). The confidence intervals are taking into account the complex survey design.
Exporting those results to an Excell file is possible.
Usage
distrib_group_continuous(
data,
group,
quanti_exp,
type = "median",
facet = NULL,
filter_exp = NULL,
...,
na.rm.group = TRUE,
na.rm.facet = TRUE,
quantiles = seq(0.1, 0.9, 0.1),
moustache_probs = c(0.95, 0.8, 0.5),
bw = 1,
resolution = 512,
height = 0.8,
limits = NULL,
reorder = FALSE,
show_mid_point = TRUE,
show_mid_line = FALSE,
show_ci_errorbar = TRUE,
show_ci_lines = FALSE,
show_ci_area = FALSE,
show_quant_lines = FALSE,
show_moustache = TRUE,
show_value = TRUE,
show_labs = TRUE,
digits = 0,
unit = "",
dec = NULL,
pal = NULL,
col_density = "#e0dfe0",
pal_moustache = NULL,
col_moustache = c("#EB9BA0", "#FAD7B1"),
color = NULL,
col_border = NA,
alpha = 1,
font = "Roboto",
wrap_width_y = 25,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
distrib_group_c(...)
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
group |
A variable defining groups to be compared. |
quanti_exp |
An expression defining the quantitatie variable the variable to be described and compared between groups. Notice that any observations with |
type |
Type of central value : |
facet |
Not yet implemented. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.group |
|
na.rm.facet |
Not yet implemented. |
quantiles |
Quantiles computed in the distributions. Default are deciles. |
moustache_probs |
A vector defining the proportions of the population used to draw the boxplot. Default is |
bw |
The smoothing bandwidth to be used. The kernels are scaled such that this is the standard deviation of the smoothing kernel. Default is |
resolution |
Resolution of the density curve. Default is |
height |
Height of the curves. Default is |
limits |
Limits of the x axe of the graphic. Does not apply to the computation. Default is |
reorder |
|
show_mid_point |
|
show_mid_line |
|
show_ci_errorbar |
|
show_ci_lines |
|
show_ci_area |
|
show_quant_lines |
|
show_moustache |
|
show_value |
|
show_labs |
|
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is none ( |
dec |
Decimal mark shown on the graphic. Depends on lang: |
pal |
For compatibility with older versions. |
col_density |
Color of the density area. It may be one color or a vector with several colors. Colors should be R color or an hexadecimal color code. In case of one color, the density is monocolor. In case of a vector, the quantile areas are painted in continuous colors going from the last color in the vector (center quantile) to the first color (first and last quantiles). In case of an even quantile area numbers (e.g. deciles, quartiles) the last color of the vector is only applied to the highcenter quantile area to avoid two continuous quantile areas having the same color. |
pal_moustache |
For compatibility with old versions. |
col_moustache |
Color of the moustache. Can be one or several colors to create a palette. In case of a vector, the different areas of the box-plot are painted in continuous colors going from the first color in the vector (center of the bo-plot) to the last color (extern area of the box-plot). |
color |
For compatibility with older versions. |
col_border |
Color of the density line. Color should be one R color or one hexadecimal color code. Default ( |
alpha |
Transparence of the density areas. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of the groups. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. If |
ylab |
Y label on the graphic. Default ( |
caption |
Caption of the graphic. This caption goes under de default caption showing the result of the Chi-Square test. There is no way of not showing the result of the statistical test as a caption. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes five sheets: the central values table, the quantile table, the densities table, the graphic and the statistical test result. |
Value
A list that contains a density table (dens), a central values table (tab), a quantile table (quant), a ggplot graphic (graph), boxplot table (moustache) and a statistical test (test).
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding eusilc$pl030 into eusilc$pl030_rec
eusilc$pl030_rec <- NA
eusilc$pl030_rec[eusilc$pl030 == "1"] <- "Working full time"
eusilc$pl030_rec[eusilc$pl030 == "2"] <- "Working part time"
eusilc$pl030_rec[eusilc$pl030 == "3"] <- "Unemployed"
eusilc$pl030_rec[eusilc$pl030 == "4"] <- "Student"
eusilc$pl030_rec[eusilc$pl030 == "5"] <- "Retired"
eusilc$pl030_rec[eusilc$pl030 == "6"] <- "Permanently disabled"
eusilc$pl030_rec[eusilc$pl030 == "7"] <- "Fulfilling domestic tasks"
# Computation, taking sample design into account
eusilc_dist_g_c <- distrib_group_c(
eusilc,
group = pl030_rec,
quanti_exp = eqIncome,
strata = db040,
ids = db030,
weight = rb050,
limits = c(0, 50000),
resolution = 128,
title = "Distribution of eq. income",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_dist_g_c$graph
# Results in table format
eusilc_dist_g_c$tab
distrib_group_discrete
Description
Function to compare the distribution of a discrete variable between different groups based on complex survey data.
It produces a list containing a table, including the confidence intervals of the indicators, a ready-to-be published ggplot graphic and a Chi-Square statistical test (using survey::svychisq()). The confidence intervals and the statistical test are taking into account the complex survey design. In case of facets, no statistical test is (yet) computed.
Exporting those results to an Excell file is possible.
Usage
distrib_group_discrete(
data,
group,
quali_var,
facet = NULL,
filter_exp = NULL,
...,
na.rm.group = TRUE,
na.rm.facet = TRUE,
na.rm.var = TRUE,
total = TRUE,
prop_method = "beta",
reorder = FALSE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
total_name = NULL,
scale = 100,
digits = 0,
unit = "",
dec = NULL,
pal = "OBSS",
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
wrap_width_leg = 25,
legend_ncol = 4,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
legend_lab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
distrib_group_d(...)
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
group |
A variable defining groups to be compared. |
quali_var |
The discrete variable described among the different groups. |
facet |
A variable defining the faceting group. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.group |
|
na.rm.facet |
|
na.rm.var |
|
total |
|
prop_method |
Type of proportion method used to compute confidence intervals. See |
reorder |
|
show_n |
|
show_value |
|
show_labs |
|
total_name |
Name of the total displayed on the graphic. Default is |
scale |
Denominator of the proportions. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit showed in the graphic. Default ( |
dec |
Decimal mark shown on the graphic. Depends on lang: |
pal |
Colors of the bars. |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. Value shoud be ranged between |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. Value shoud be ranged between |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of the groups. Default is |
wrap_width_leg |
Number of characters before going to the line for the labels of |
legend_ncol |
Number of columns in the legend. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
legend_lab |
Legend (fill) label on the graphic. Default ( |
caption |
Caption of the graphic. This caption goes under de default caption showing the result of the Chi-Square test. There is no way of not showing the result of the chi-square test as a caption. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes three (without facets) or two sheets (with facets): the table, the graphic and the Chi-Square statistical test result. |
Value
A list that contains a table, a ggplot graphic and, in most cases, a Chi-square statistical test.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding eusilc$pl030 into eusilc$pl030_rec
eusilc$pl030_rec <- NA
eusilc$pl030_rec[eusilc$pl030 == "1"] <- "Working full time"
eusilc$pl030_rec[eusilc$pl030 == "2"] <- "Working part time"
eusilc$pl030_rec[eusilc$pl030 == "3"] <- "Unemployed"
eusilc$pl030_rec[eusilc$pl030 == "4"] <- "Student"
eusilc$pl030_rec[eusilc$pl030 == "5"] <- "Retired"
eusilc$pl030_rec[eusilc$pl030 == "6"] <- "Permanently disabled"
eusilc$pl030_rec[eusilc$pl030 == "7"] <- "Fulfilling domestic tasks"
# Computation, taking sample design into account
eusilc_dist_d <- distrib_group_d(
eusilc,
group = pb220a,
quali_var = pl030_rec,
strata = db040,
ids = db030,
weight = rb050,
title = "Distribution of socio-economic status according to nationality",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_dist_d$graph
# Results in table format
eusilc_dist_d$tab
esth_graph
Description
Function to construct a graphic following the aestetics of the other functions of functionr from a table. This function was created to align results generated outside fonctionr with the outputs of fonctionr.
Usage
esth_graph(
tab,
var,
value,
error_low = NULL,
error_upp = NULL,
facet = NULL,
n_var = NULL,
pvalue = NULL,
reorder = FALSE,
show_value = TRUE,
name_total = NULL,
scale = 1,
digits = 2,
unit = "",
dec = ",",
pal = NULL,
col = "indianred4",
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
theme = "fonctionr",
coef_font = 1
)
Arguments
tab |
dataframe with the indicators to be ploted. |
var |
The variable in |
value |
The variable in |
error_low |
The variable in |
error_upp |
The variable in |
facet |
A variable in |
n_var |
The variable in |
pvalue |
The p-value to show in the caption. It can be a numeric value or the pvalue object from a statistical test. |
reorder |
|
show_value |
|
name_total |
Name of the |
scale |
Denominator of the indicator. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
The unit displayed on the grphaic. Default is no unit ( |
dec |
Decimal mark shown on the graphic. Default is |
pal |
For compatibility with old versions. |
col |
Color of the bars. |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
caption |
Caption of the graphic. |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
Value
A ggplot graphic.
Examples
# Making fictional dataframe
data_test <- data.frame(
Indicators = c(
"Variable 1",
"Variable 2",
"Variable 3",
"Variable 4",
"Variable 5",
"Tot"
),
Estimates = c(1.52, 1.63, 2.34, 4.15, 1.32, 2.13),
IC_low = c(1.32, 1.4, 1.98, 4, 14.2, 26),
IC_upp = c(1.73, 1.81, 22.4, 47.44, 1.45, 2.34),
sample_size = c(215, 300, 129, 212, 189, 1045)
)
# Using dataframe to make a plot
plot_test <- esth_graph(data_test,
var = Indicators,
value = Estimates,
error_low = IC_low,
error_upp = IC_upp,
n_var = sample_size,
pvalue = .001,
reorder = TRUE,
show_value = TRUE,
name_total = "Tot",
scale = 1,
digits = 1,
unit = "%",
dec = ".",
col = "green4",
dodge = 0.8,
font = "Montserrat",
wrap_width_y = 25,
title = "Plot",
subtitle = "Using fake data",
xlab = "Proportion (in %)",
ylab = "Indicators",
caption = "Source: fictional own calculation",
theme = "IWEPS"
)
# Result is a ggplot
plot_test
fonctionr_options
Description
Function to set global options for fonctionr. The arguments defined in the options are only active if the user has not manually specified a value for those arguments within the various functions. Arguments may be shared by multiple functions (if they have the same name) or specific to certain functions.
Usage
fonctionr_options(
na.rm.group = NULL,
na.rm.facet = NULL,
na.prop = NULL,
na.vars = NULL,
na.rm.var = NULL,
probs = NULL,
total = NULL,
prop_method = NULL,
quantiles = NULL,
moustache_probs = NULL,
bw = NULL,
resolution = NULL,
height = NULL,
limits = NULL,
reorder = NULL,
position = NULL,
show_ci = NULL,
show_mid_point = NULL,
show_mid_line = NULL,
show_ci_errorbar = NULL,
show_ci_lines = NULL,
show_ci_area = NULL,
show_quant_lines = NULL,
show_moustache = NULL,
show_n = NULL,
show_value = NULL,
show_labs = NULL,
total_name = NULL,
scale = NULL,
digits = NULL,
unit = NULL,
dec = NULL,
col = NULL,
pal = NULL,
direction = NULL,
desaturate = NULL,
lighten = NULL,
darken = NULL,
col_density = NULL,
col_moustache = NULL,
col_border = NULL,
alpha = NULL,
dodge = NULL,
font = NULL,
wrap_width_y = NULL,
wrap_width_leg = NULL,
legend_ncol = NULL,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
legend_lab = NULL,
caption = NULL,
lang = NULL,
theme = NULL,
coef_font = NULL,
parallel = NULL,
erase_all = FALSE
)
Arguments
na.rm.group |
|
na.rm.facet |
|
na.prop |
|
na.vars |
|
na.rm.var |
|
probs |
|
total |
|
prop_method |
|
quantiles |
|
moustache_probs |
|
bw |
|
resolution |
|
height |
|
limits |
|
reorder |
|
position |
|
show_ci |
|
show_mid_point |
|
show_mid_line |
|
show_ci_errorbar |
|
show_ci_lines |
|
show_ci_area |
|
show_quant_lines |
|
show_moustache |
|
show_n |
|
show_value |
|
show_labs |
|
total_name |
|
scale |
|
digits |
|
unit |
|
dec |
|
col |
|
pal |
|
direction |
|
desaturate |
|
lighten |
|
darken |
|
col_density |
|
col_moustache |
|
col_border |
|
alpha |
|
dodge |
|
font |
|
wrap_width_y |
|
wrap_width_leg |
|
legend_ncol |
|
title |
|
subtitle |
|
xlab |
|
ylab |
|
legend_lab |
|
caption |
|
lang |
|
theme |
|
coef_font |
|
parallel |
|
erase_all |
|
Value
No return value, called for side effects.
Examples
# We set global settings
fonctionr_options(coef_font = 1.5, col = "magenta", caption = "Beautiful caption")
# Loading of data
data(eusilc, package = "laeken")
# Recoding eusilc$pl030 into eusilc$pl030_rec
eusilc$pl030_rec <- NA
eusilc$pl030_rec[eusilc$pl030 == "1"] <- "Working full time"
eusilc$pl030_rec[eusilc$pl030 == "2"] <- "Working part time"
eusilc$pl030_rec[eusilc$pl030 == "3"] <- "Unemployed"
eusilc$pl030_rec[eusilc$pl030 == "4"] <- "Student"
eusilc$pl030_rec[eusilc$pl030 == "5"] <- "Retired"
eusilc$pl030_rec[eusilc$pl030 == "6"] <- "Permanently disabled"
eusilc$pl030_rec[eusilc$pl030 == "7"] <- "Fulfilling domestic tasks"
# Computation, taking sample design into account
eusilc_prop <- prop_group(
eusilc,
group = pl030_rec,
prop_exp = py090n > 0,
weight = rb050,
title = "% of ind. receiving unemployment benefits in their hh",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_prop$graph
# We set back settings to default
fonctionr_options(erase_all = TRUE)
load_and_active_fonts
Description
Function to load and activate fonctionr's built-in fonts.
Available fonts, included in the package itself, are "Roboto", "Montserrat", "Gotham Narrow", and "Euclid Circular A". Default is "Roboto".
Usage
load_and_active_fonts()
Value
No return value, called for side effects.
Examples
# Loading of fonts from fonctionr. You can now use it in fonctionr !
load_and_active_fonts()
make_surface
Description
Function that represents the values of a group variable as areas proportional to those values.
Usage
make_surface(
tab,
var,
value,
error_low = NULL,
error_upp = NULL,
facet = NULL,
pvalue = NULL,
reorder = FALSE,
compare = FALSE,
space = NULL,
position = "mid",
show_ci = TRUE,
name_total = "Total",
digits = 0,
unit = NULL,
col = NULL,
pal = "OBSS_Autumn",
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
size_text = 3.88,
bg = "#f8f5f5",
linewidth_ci = 0.5,
ratio = 3/2,
font = "Roboto",
wrap_width_lab = 20,
title = NULL,
subtitle = NULL,
hjust.title = 0,
caption = NULL,
coef_font = 1
)
Arguments
tab |
dataframe with the variables to be ploted. |
var |
The variable in |
value |
The variable in |
error_low |
The variable in |
error_upp |
The variable in |
facet |
A variable in |
pvalue |
The p-value to show in the caption. It can be a numeric value or the pvalue object from a statistical test. |
reorder |
|
compare |
|
space |
The space between the rectangles. The unit is that of the indicator. |
position |
The position of the rectangles: |
show_ci |
|
name_total |
Name of the |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
The unit showd on the plot. Default is none ( |
col |
Color of the rectangles if the user wants a monocolor graph. |
pal |
Colors of the rectangles if the user wants the rectangles to have different colors. |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. Value shoud be ranged between |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. Value shoud be ranged between |
size_text |
Text size displayed in rectangles . Default is |
bg |
Color of the background. |
linewidth_ci |
Line width of the dotted confidence intervals lines. It affects also the lenghts of the dots and spaces bteween dots. Default is |
ratio |
Ratio between the length and the width of the rectangles. |
font |
Font used in the graphic. See |
wrap_width_lab |
Number of characters before going to the line for the labels of the categories of |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
hjust.title |
Horizontal alignment of title & subtitle. It should take a numeric value. Default ( |
caption |
Caption of the graphic. |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
Value
A ggplot graphic.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding eusilc$pl030 into eusilc$pl030_rec
eusilc$pl030_rec <- NA
eusilc$pl030_rec[eusilc$pl030 == "1"] <- "Working full time"
eusilc$pl030_rec[eusilc$pl030 == "2"] <- "Working part time"
eusilc$pl030_rec[eusilc$pl030 == "3"] <- "Unemployed"
eusilc$pl030_rec[eusilc$pl030 == "4"] <- "Student"
eusilc$pl030_rec[eusilc$pl030 == "5"] <- "Retired"
eusilc$pl030_rec[eusilc$pl030 == "6"] <- "Permanently disabled"
eusilc$pl030_rec[eusilc$pl030 == "7"] <- "Fulfilling domestic tasks"
# Calculation of income means by age category with fonctionr, taking sample design into account
eusilc_mean <- mean_group(
eusilc,
group = pl030_rec,
quanti_exp = py010n + py050n + py090n + py100n + py110n + py120n + py130n + py140n,
filter_exp = !pl030_rec %in% c("Student", "Fulfilling domestic tasks") & db040 == "Tyrol",
weights = rb050
)
# Displaying results with make_surface()
eusilc_mean$tab |>
make_surface(
var = pl030_rec,
value = mean,
error_low = mean_low,
error_upp = mean_upp,
reorder = TRUE,
wrap_width_lab = 15,
unit = "€",
title = "Equivalised income in household by socio-economic status",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
many_val
Description
Function to compute the proportions of a set of several binary variables or means or medians of a set of quantitative variables, based on complex survey data.
It produces a list containing a table, including the confidence intervals of the indicators and a ready-to-be published ggplot graphic. The confidence intervals are taking into account the complex survey design.
Exporting the results to an Excell file is possible.
Usage
many_val(
data,
list_vars,
type,
list_vars_lab = NULL,
facet = NULL,
filter_exp = NULL,
...,
na.rm.facet = TRUE,
na.vars = "rm",
prop_method = "beta",
reorder = FALSE,
show_ci = TRUE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
scale = NULL,
digits = 0,
unit = NULL,
dec = NULL,
col = NULL,
pal = "OBSS_alt3",
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
many_prop(..., type = "prop")
many_median(..., type = "median")
many_mean(..., type = "mean")
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
list_vars |
A vector containing the names of the dummy/quantitative variables on which to compute the proportions/means/medians. |
type |
|
list_vars_lab |
A vector containing the labels of the dummy/quantitative variables to be displayed on the graphic and in the table of result. Default uses the variable names in |
facet |
A variable defining the faceting group. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.facet |
|
na.vars |
The treatment of |
prop_method |
Type of proportion method used to compute confidence intervals. See |
reorder |
|
show_ci |
|
show_n |
|
show_value |
|
show_labs |
|
scale |
Denominator of the proportions. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is percent for |
dec |
Decimal mark displayed on the graphic. Default depends on lang: |
col |
Color of the bars if the user wants a monocolor graph. |
pal |
Colors of the bars if the user wants the bars to have different colors. |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. Value shoud be ranged between |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. Value shoud be ranged between |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of the groups. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
caption |
Caption of the graphic. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes two sheets: the table and the graphic. |
Value
A list that contains a table and a ggplot graphic.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding variables
eusilc$worker <- 0
eusilc$worker[eusilc$pl030 == "1"]<-1
eusilc$worker[eusilc$pl030 == "2"]<-1
eusilc$austrian<-0
eusilc$austrian[eusilc$pb220a == "AT"]<-1
# Computation, taking sample design into account
eusilc_many_prop <- many_prop(
eusilc,
list_vars = c(worker,austrian),
list_vars_lab = c("% of workers","% of Austrian"),
facet = rb090,
strata = db040,
ids = db030,
weight = rb050,
title = "Proportion of workers and Autrian according to gender",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_many_prop$graph
# Results in table format
eusilc_many_prop$tab
many_val_group
Description
Function to compare de proportions/means/medians of a set of several binary/quantitatives variables between different groups, based on complex survey data. It produces a list containing a table, including the confidence intervals of the indicators and a ready-to-be published ggplot graphic. The confidence intervals are taking into account the complex survey design.
Exporting the results to an Excell file is possible.
Usage
many_val_group(
data,
group,
list_vars,
type,
list_vars_lab = NULL,
facet = NULL,
filter_exp = NULL,
...,
na.rm.group = TRUE,
na.rm.facet = TRUE,
na.vars = "rm",
total = TRUE,
prop_method = "beta",
position = "dodge",
show_ci = TRUE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
total_name = NULL,
scale = NULL,
digits = 0,
unit = NULL,
dec = NULL,
pal = "OBSS_alt3",
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
wrap_width_leg = 25,
legend_ncol = 4,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
legend_lab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL,
parallel = NULL
)
many_prop_group(..., type = "prop")
many_median_group(..., type = "median")
many_mean_group(..., type = "mean")
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
group |
A variable defining groups to be compared. |
list_vars |
A vector containing the names of the dummy/quantitative variables on which to compute the proportions/means/medians. |
type |
|
list_vars_lab |
A vector containing the labels of the dummy/quantitative variables to be displayed on the graphic and in the table of result. Default uses the variable names in |
facet |
A variable defining the faceting group. |
filter_exp |
An expression filtering the data, preserving the design. Notice that filter_exp works as |
... |
All options possible in |
na.rm.group |
|
na.rm.facet |
|
na.vars |
The treatment of |
total |
|
prop_method |
Type of proportion method used to compute confidence intervals. See |
position |
Position adjustment for the ggplot. Default is |
show_ci |
|
show_n |
|
show_value |
|
show_labs |
|
total_name |
Name of the total bars on the graphic. Default is Total. Notice that total is not displayed nor computed if |
scale |
Denominator of the proportions. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is percent for |
dec |
Decimal mark displayed on the graphic. Default depends on lang: |
pal |
Colors of the bars. |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. Value shoud be ranged between |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. Value shoud be ranged between |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels on de Y axe (groups if |
wrap_width_leg |
Number of characters before going to the line for the labels the legend (variables if |
legend_ncol |
Number maximum of columns in the legend. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
legend_lab |
Legend (fill) label on the graphic. Default ( |
caption |
Caption of the graphic. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes two sheets: the table and the graphic. |
parallel |
|
Value
A list that contains a table and a graphic.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding variables
eusilc$worker <- 0
eusilc$worker[eusilc$pl030 == "1"] <- 1
eusilc$worker[eusilc$pl030 == "2"] <- 1
eusilc$austrian <- 0
eusilc$austrian[eusilc$pb220a == "AT"] <- 1
# Computation, taking sample design into account
eusilc_many_mean_group <- many_mean_group(
eusilc,
group = rb090,
list_vars = c(py010n,py050n,py090n,py100n),
list_vars_lab = c("Wage","Self-employement income","unemployement benefit","pension"),
strata = db040,
ids = db030,
weight = rb050,
title = "Average incomes according to gender",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_many_mean_group$graph
# Results in table format
eusilc_many_mean_group$tab
official_pal
Description
A function that allows you to create the palettes of fonctionr.
Usage
official_pal(
inst,
n,
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
show_pal = FALSE,
font = "Gotham Narrow",
list_pal_names = FALSE
)
Arguments
inst |
Name of the palette. |
n |
Number of colors. |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. |
show_pal |
|
font |
Font used in the graphic. See |
list_pal_names |
|
Value
A vector containing hexadecimals color codes.
Examples
official_pal("OBSS", 8, show_pal = TRUE)
official_pal("OBSS_Greens", 8, show_pal = TRUE)
official_pal("OBSS_div_mid4", 7, show_pal = TRUE)
official_pal("OBSS_div_bi3", 8, show_pal = TRUE)
official_pal("IBSA", 4, show_pal = TRUE)
official_pal("ULB", 6, show_pal = TRUE)
pivot_longer_survey
Description
Function to pivot, from wide to long, a dataframe produced by srvyr::summarise() with results by group(s).
Usage
pivot_longer_survey(data, n_groups)
Arguments
data |
A dataframe produced by |
n_groups |
Number of groups by which data has been agregated. |
Value
A pivoted dataframe
Examples
# Loading data
data(eusilc, package = "laeken")
# Loading srvyr
library(srvyr)
# Making srvyr object
eusilc_srvyr <- as_survey_design(eusilc, ids = db030, strata = db040, weights = rb050)
# computing srvyr result using summarise()
result_srvyr<-eusilc_srvyr |>
group_by(rb090, pb220a) |> # by sex and nationality
summarise(mean_eqIncome = survey_mean(eqIncome), mean_age = survey_mean(age))
# Showing the srvyr summirise output
result_srvyr
# Pivoting the out with pivot_longer_survey()
pivoted_result <- pivot_longer_survey(result_srvyr, n_groups = 2)
# Output is pivoted
pivoted_result
prop_group
Description
Function to compare a proportion among different groups based on complex survey data. It produces a list containing a table, including the confidence intervals of the indicators, a ready-to-be published ggplot graphic and a Chi-Square statistical test (using survey::svychisq()).
The confidence intervals and the statistical test are taking into account the complex survey design. In case of facets, the Chi-square test is computed on the total proportion between facets (and not within facets). In case of second group (group.fill), no Chi-square test is computed.
Exporting those results to an Excell file is possible.
Usage
prop_group(
data,
group,
prop_exp,
group.fill = NULL,
facet = NULL,
filter_exp = NULL,
...,
na.rm.group = TRUE,
na.rm.facet = TRUE,
na.prop = "rm",
total = TRUE,
prop_method = "beta",
reorder = FALSE,
show_ci = TRUE,
show_n = FALSE,
show_value = TRUE,
show_labs = TRUE,
total_name = NULL,
scale = 100,
digits = 0,
unit = "%",
dec = NULL,
col = "deepskyblue3",
pal = "OBSS_Relax",
direction = 1,
desaturate = 0,
lighten = 0,
darken = 0,
dodge = 0.9,
font = "Roboto",
wrap_width_y = 25,
wrap_width_leg = 25,
legend_ncol = 4,
title = NULL,
subtitle = NULL,
xlab = NULL,
ylab = NULL,
legend_lab = NULL,
caption = NULL,
lang = "fr",
theme = "fonctionr",
coef_font = 1,
export_path = NULL
)
Arguments
data |
A dataframe or an object from the survey package or an object from the srvyr package. |
group |
A variable defining the groups to be compared. |
prop_exp |
An expression defining the proportion to be computed. Notice that if |
group.fill |
A variable defining a second variable of groups to be compared. |
facet |
A variable defining the faceting groups. |
filter_exp |
An expression filtering the data, preserving the design. Notice that |
... |
All options possible in |
na.rm.group |
|
na.rm.facet |
|
na.prop |
|
total |
|
prop_method |
Type of proportion method used to compute confidence intervals. See |
reorder |
|
show_ci |
|
show_n |
|
show_value |
|
show_labs |
|
total_name |
Name of the total displayed on the graphic. Default is |
scale |
Denominator of the proportions. Default is |
digits |
Number of decimal places displayed on the values labels on the graphic. Default is |
unit |
Unit displayed on the graphic. Default is |
dec |
Decimal mark displayed on the graphic. Default depends on lang: |
col |
Color of the bars if there is no |
pal |
Colors of the bars if there is a |
direction |
Direction of the palette color. Default is |
desaturate |
Numeric specifying the amount of desaturation where |
lighten |
Numeric specifying the amount of lightening. Negative numbers cause darkening. Value shoud be ranged between |
darken |
Numeric specifying the amount of lightening. Negative numbers cause lightening. Value shoud be ranged between |
dodge |
Width of the bars. Default is |
font |
Font used in the graphic. See |
wrap_width_y |
Number of characters before going to the line for the labels of the groups. Default is |
wrap_width_leg |
Number of characters before going to the line for the labels of the |
legend_ncol |
Number of columns in the legend. Default is |
title |
Title of the graphic. |
subtitle |
Subtitle of the graphic. |
xlab |
X label on the graphic. As |
ylab |
Y label on the graphic. As |
legend_lab |
Legend (fill) label on the graphic. Default ( |
caption |
Caption of the graphic. This caption goes under de default caption showing the result of the Chi-Square test. There is no way of not showing the result of the chi-square test as a caption. |
lang |
Language of the indications on the graphic. Possibilities are |
theme |
Theme of the graphic. Default is |
coef_font |
A multiplier factor for font size of all fonts on the graphic. Default is |
export_path |
Path to export the results in an xlsx file. The file includes three (without |
Value
A list that contains a table, a ggplot graphic and, in most cases, a Chi-square statistical test.
Examples
# Loading of data
data(eusilc, package = "laeken")
# Recoding eusilc$pl030 into eusilc$pl030_rec
eusilc$pl030_rec <- NA
eusilc$pl030_rec[eusilc$pl030 == "1"] <- "Working full time"
eusilc$pl030_rec[eusilc$pl030 == "2"] <- "Working part time"
eusilc$pl030_rec[eusilc$pl030 == "3"] <- "Unemployed"
eusilc$pl030_rec[eusilc$pl030 == "4"] <- "Student"
eusilc$pl030_rec[eusilc$pl030 == "5"] <- "Retired"
eusilc$pl030_rec[eusilc$pl030 == "6"] <- "Permanently disabled"
eusilc$pl030_rec[eusilc$pl030 == "7"] <- "Fulfilling domestic tasks"
# Computation, taking sample design into account
eusilc_prop <- prop_group(
eusilc,
group = pl030_rec,
prop_exp = py090n > 0,
strata = db040,
ids = db030,
weight = rb050,
title = "% of ind. receiving unemployment benefits in their hh",
subtitle = "Example with austrian SILC data from 'laeken' package"
)
# Results in graph form
eusilc_prop$graph
# Results in table format
eusilc_prop$tab
relab_cut
Description
Function to recode the default labels of a factor created by cut() from base R into more intuitive labels.
Usage
relab_cut(vec, suffix = NULL, right = TRUE, lang = "fr")
Arguments
vec |
The vector to be recoded. It should be produced by |
suffix |
The suffix to be indicated after the values. Usualy, the unit of the variable will be used (e.g. euros, percents). Default is |
right |
|
lang |
Language of new labels. Possibilities are |
Value
A vector with new labels.
Examples
cut(1:1000, breaks = 5, include.lowest = TRUE, right = FALSE, dig.lab = 4) |>
table()
cut(1:1000, breaks = 5, include.lowest = TRUE, right = FALSE, dig.lab = 4) |>
relab_cut(suffix = "€", right = FALSE) |>
table()
theme_fonctionr
Description
A ggplot theme that is ready to use. It is used by most other functions, but can also be applied to an external ggplot object.
Usage
theme_fonctionr(
font = "Roboto",
theme = "fonctionr",
display = "ggplot",
grid.lines = "x",
coef_font = 1
)
Arguments
font |
Font used in the graphic. See |
theme |
The optionnal theme you want for the graphic. Available themes: |
display |
The way |
grid.lines |
Specify major grid lines : |
coef_font |
A multiplier factor for font size. |
Value
No return value, called for side effects.