graph_departure {convergEU} | R Documentation |
Graphical representation based on sigma convergence
Description
A ggplot object countries by time where coloured rectangles show if in that time unit the indicator is below one standard deviation (-1) from the mean, above one standard deviation (-1) from the mean or within 2 standard deviations around the mean.
Usage
graph_departure(
myTB,
timeName = "time",
indiType = "highBest",
displace = 0.25,
displaceh = 0.45,
dimeFontNum = 6,
myfont_scale = 1.35,
x_angle = 45,
color_rect = c(`-1` = "red1", `0` = "gray80", `1` = "lightskyblue1"),
axis_name_y = "Countries",
axis_name_x = "Time",
alpha_color = 0.9
)
Arguments
myTB |
the component $res$departure of an object created by
|
timeName |
name of the time variable |
indiType |
indicator type, one among "highBest" and "lowBest" |
displace |
rectangle half height |
displaceh |
rectangle half base |
dimeFontNum |
size of font |
myfont_scale |
axes magnification |
x_angle |
angle of x axis labels |
color_rect |
colors within rectangles; the default for a "highBest" indicator type is red for "-1", grey for "0" and light sky blue for "1"; the default for a "lowBest" indicator type is light sky blue for "-1", grey for "0" and red for "1" |
axis_name_y |
name of y axis |
axis_name_x |
name of x axis |
alpha_color |
transparency |
Details
Note that calculation of departure must be already performed by invoking
departure_mean
.
Value
a list with component $res made by a ggplot object to be displayed or saved using ggsave function.
References
Examples
# Example 1: "lowBest" indicator type:
# Dataframe 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
)
mySTB <- sigma_conv(testTB)
resDM <- departure_mean(oriTB=testTB, sigmaTB=mySTB$res)
myG <- NULL
myG <- graph_departure(resDM$res$departures,
timeName = "time",
indiType = "lowBest",
displace = 0.25,
displaceh = 0.45,
dimeFontNum = 6,
myfont_scale = 1.35,
x_angle = 45,
axis_name_y = "Countries",
axis_name_x = "Time",
alpha_color = 0.9)
# Change the colour of rectangles:
myGG <- graph_departure(resDM$res$departures,
timeName = "time",
indiType = "lowBest",
displace = 0.25,
displaceh = 0.45,
dimeFontNum = 6,
myfont_scale = 1.35,
x_angle = 45,
color_rect = c("-1"='green4', "0"='yellow',"1"='red'),
axis_name_y = "Countries",
axis_name_x = "Time",
alpha_color = 0.9)
# Example 2: "highBest" type of indicator:
# Graphical plot of sigma convergence for the emp_20_64_MS Eurofound dataset:
data(emp_20_64_MS)
mySC <- sigma_conv(emp_20_64_MS)
resDMeur <- departure_mean(oriTB = emp_20_64_MS, sigmaTB = mySC$res)
myG1 <- NULL
myG1 <- graph_departure(resDMeur$res$departures,
timeName = "time",
indiType = "highBest",
displace = 0.25,
displaceh = 0.45,
dimeFontNum = 6,
myfont_scale = 1.35,
x_angle = 45,
axis_name_y = "Countries",
axis_name_x = "Time",
alpha_color = 0.9)
# Plot mean departures for selected countries only and change the colour of rectangles:
myG2 <- NULL
myG2 <- graph_departure(resDMeur$res$departures[,1:8],
timeName = "time",
indiType = "highBest",
displace = 0.25,
displaceh = 0.45,
dimeFontNum = 6,
myfont_scale = 1.35,
x_angle = 45,
color_rect = c("-1"='red', "0"='yellow',"1"='green4'),
axis_name_y = "Countries",
axis_name_x = "Time",
alpha_color = 0.9)