plt_boxplot: Plot distribution of a variable as boxplot from a data set

Description Usage Arguments Examples

View source: R/plt_boxplot.R

Description

Plot the distribution of a variable from a data set. Default is the EntrancesData data set. The distribution can be plotted either for all observations or individually for each year or each region (e.g. NUTS3) The plot can be saved as png and printed in the R Studio plot window.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
plt_boxplot(
  VarName,
  data = EntrancesData,
  distribution_of = "all",
  years = "all",
  nuts_ids = "all",
  print_plot = TRUE,
  save_png = F,
  legend_labels = "default",
  folder_for_png = "Plots",
  NUTS_level = "all"
)

Arguments

VarName

character string o with the name of the variable which shall be plotted.

data

data_frame containing the data you want to use. It must contain a column called year containing the years of the observation, a column called value containing the variable values and a column called NUTS_ID with regional IDs. Default is the EntrancesData dataset.

distribution_of,

"region", "year" or "all", determines if one box shows the distribution of the values for a region, for a year or for all values of the variable

years

integer vector containing all years for which the data should be plotted. Default is all years contained in the dataset

nuts_ids,

sting vector with NUTS IDs which should be plotted. Default is "all", selecting all NUTS IDs in the dataset for plotting.

print_plot

logical, if TRUE, the plot is displayed in the Plot window

save_png

logical, if TRUE, a png of the plot is saved.

legend_labels,

vector with legend labels, if set to "default", NUTS/region IDs are used. Legend labels can only be changed, when distribution_of is set to "region" and the number of regions is smaller than 12. Otherwise default legend labels are used.

folder_for_png

string, name of the folder in the working directory where a picture of the plots should be saved. folder="wd" saves plots directly in the working directory. Default is the folder Plots in the working directory. If the folder doesn't exist, the function creates a new folder in the working directory.

NUTS_level

string, plots data only for a specific NUTS level. default is "all", so all data is plotted. Other possible inputs: "NUTS3", "NUTS2","NUTS1","NUTS country"

Examples

1
plt_boxplot(VarName="unp_%", data=EntrancesData, distribution_of="year", years=c(2000:2020), nuts_ids=c("IT", "PL", "RO"), print_plot=TRUE, save_png=FALSE, legend_labels=c("Italy", "Poland", "Romania"), folder_for_png="Plots", NUTS_level="all")

THartl1/EntrancesDataPackage documentation built on Dec. 18, 2021, 4:01 p.m.