Applies descdata to the selected columns and produces a plot showing the descriptive statistics. The plot is generated using ggplot2 and a suitable melt function.
descplot(data, cols = NULL, stats = 1:9, first = "variables",
ncol = NULL, num_xaxis = "log", verbose = FALSE)A ggplot object displaying the descriptive statistics.
A data frame containing numeric columns to describe.
Column indices or names of numeric variables. If NULL, all numeric columns are used.
Statistics to plot, as in descdata.
Name for the variable identifier column (passed to descdata).
Number of columns in the facet layout (passed to facet_wrap).
How to treat numeric column names on the x-axis. Options:
"log" (default): if all selected column names are numeric, convert to numeric and use log10 scale;
"numeric": convert to numeric but use linear scale;
"character", "factor", "keep", or FALSE: keep as character/factor (no conversion).
Logical; if TRUE, prints timing message.
Chun-Sheng Liang <[email protected]>
This function first calls descdata and then melts the result into a long format suitable for ggplot2. If the column names of the original data are numeric, the plot uses a logarithmic x-axis and line geometry; otherwise, a bar plot is produced. The num_xaxis parameter allows overriding the default log transform.
1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest. 2. Wickham, H. 2016. ggplot2: elegant graphics for data analysis. Springer-Verlag New York.
descplot(data, cols = 5:65)
descplot(data, cols = 5:65, stats = c("min","max","IQR"), num_xaxis = "numeric")
Run the code above in your browser using DataLab