durPlot: Graphs and Summary for Date Durations

Description Usage Arguments Details Author(s) See Also Examples

View source: R/durPlot.R

Description

Plots boxplot, histogram, density plot, scatter plot, line plot and prints summary statistics for date duration data.

Usage

1
2
3
4
5
6
7
durPlot(df, start, end, group = NA, timeunit = "days", plot_type = "all",
       facet = FALSE, facet.nrow = NULL, theme = NULL, other = NULL,
       fill_color = "black", line_color = "black", groupcolor = TRUE,
       point_size = 2, alpha = NA, binwidth = 0.5, show_legend = TRUE,
       title=FALSE, title_boxplot = "Boxplot", title_histogram = "Histogram",
       title_density = "Density Plot", title_scatter = "Scatter Plot",
       title_line = "Line Plot")

Arguments

df

Data frame containing start dates, end dates and groups.

start

Column in df for start dates.

end

Column in df for end dates.

group

Column in df for groups. Default is NA.

timeunit

Unit of time to be used in plots. "day(s)", "week(s)", "month(s)", "quarter(s)", "semiannual", "halfyear",or "year(s)".

plot_type

One of "all", "boxplot", "histogram", "density", "scatter", "line". Default is "all".

facet

If TRUE, wraps plots in group facets

facet.nrow

Number of rows for facet wrap

theme

Add theme elements if needed.

other

Add other elements if needed.

fill_color

Fill color

line_color

Line color

groupcolor

If FALSE, fill_color and line_color used for all groups. Default is TRUE.

point_size

Point size for scatterplot

alpha

Color transparency [0,1]

binwidth

Binwidth for histogram; default 0.5.

show_legend

Default is TRUE

title

If TRUE, puts main titles for each plot

title_boxplot

Title for boxplot title

title_histogram

Title for histogram

title_density

Title for density plot

title_scatter

Title for scatter plot

title_line

Title for line plot

Details

The function also returns summary statistics for the specified date duration.

Author(s)

Dahee Lee

See Also

timelineS, timelineG, durSummary, durCalc

Examples

1
2
3
4
5
durPlot(life_exp, start = "Birth", end = "Death", group = "Country",
timeunit = "years", facet = TRUE, binwidth = 3, alpha = 0.7, title = TRUE)

durPlot(life_exp, start = "Birth", end = "Death", group = "Country",
timeunit = "years",alpha = 0.5, title = TRUE)

Example output

    Country   min   Qt1 median  mean   Qt3   max   sd
1 Australia 67.19 72.16  76.26 75.72 78.98 85.71 5.30
2     China 67.41 70.09  76.06 76.44 83.38 87.56 7.14
3    France 64.02 68.16  74.48 74.89 79.10 89.37 7.59
4     Japan 69.35 75.14  77.76 77.63 80.57 85.33 4.82
5        US 62.73 72.04  76.21 75.35 79.00 85.45 5.49
    Country   min   Qt1 median  mean   Qt3   max   sd
1 Australia 67.19 72.16  76.26 75.72 78.98 85.71 5.30
2     China 67.41 70.09  76.06 76.44 83.38 87.56 7.14
3    France 64.02 68.16  74.48 74.89 79.10 89.37 7.59
4     Japan 69.35 75.14  77.76 77.63 80.57 85.33 4.82
5        US 62.73 72.04  76.21 75.35 79.00 85.45 5.49

timelineS documentation built on May 2, 2019, 8:57 a.m.