dev_mean_plot: Plot of deviations from the mean

View source: R/dev_mean_plot.R

dev_mean_plotR Documentation

Plot of deviations from the mean

Description

Negative deviations and positive deviations are added over years and plotted by country.

Usage

dev_mean_plot(
  myTB,
  timeName = "time",
  time_0 = NA,
  time_t = NA,
  countries = c(NA, NA),
  indiType = "highBest",
  displace = 0.25,
  axis_name_y = "Countries",
  val_alpha = 0.95,
  debug = FALSE
)

Arguments

myTB

a dataset time by countries

timeName

name of the variable representing time

time_0

starting time

time_t

ending time

countries

selection of countries to display; NA means all countries

indiType

the type of indicator "highBest" or "lowBest"

displace

graphical displacement

axis_name_y

name of the axis

val_alpha

transparency value in (0,1].

debug

a flag to get debug information as msg component

Value

a list with ggplot2 graphical object within res component

References

https://unimi2013-my.sharepoint.com/:u:/g/personal/federico_stefanini_unimi_it/EW0cVSIgbtZAvLPNbqcxdX8Bfn5VGSRHfAH88hQwc_RIEQ?e=MgtSZu

Examples



# Example 1
# A dataset in the format time by countries:
require(tibble)
testTB <- dplyr::tribble(
~time, ~countryA ,  ~countryB,  ~countryC,
2000,     0.8,   2.7,    3.9,
2001,     1.2,   3.2,    4.2,
2002,     0.9,   2.9,    4.1,
2003,     1.3,   2.9,    4.0,
2004,     1.2,   3.1,    4.1,
2005,     1.2,   3.0,    4.0
)
# Plot the deviations from the mean for all countries:
resDMP <- dev_mean_plot(testTB,
                        timeName="time",
                        displace = 0.25,
                        axis_name_y = "Countries")
resDMP

# Plot by considering only some of the years:
resDMP1 <- dev_mean_plot(testTB,
                       timeName="time",
                       time_0 = 2002,
                       time_t = 2004,
                       displace = 0.25,
                       axis_name_y = "Countries")
resDMP1

# Example 2
# The Eurofound dataset "emp_20_64_MS":
myTB1 <- emp_20_64_MS

# Plot the deviations from the mean only for some of the member states:
resDMP2 <- dev_mean_plot(myTB1,
                       timeName="time",
                       time_0 = 2005,
                       time_t = 2010,
                       countries= c("AT","BE","IT"),
                       displace = 0.25,
                       axis_name_y = "Countries")
resDMP2



convergEU documentation built on March 7, 2023, 7:22 p.m.