funq_plot()
conditions on variable x
with quantile binning and
plots the median and interquartile range of numerical variables and level frequency
of the other variables as a function the x
variable.
funq_plot(
data,
x = NULL,
n = 100,
min_bin_size = NULL,
overlap = NULL,
color = "#002f2f",
fill = "#2f4f4f",
auto_fill = TRUE,
ncols = NULL,
xmarker = NULL,
qmarker = NULL,
show_bins = FALSE,
xlim = NULL,
connect = TRUE,
...
)
a data.frame
to be binned
character
variable name used for the quantile binning
integer
number of quantile bins.
integer
minimum number of rows/data points that should be
in a quantile bin. If NULL it is initially sqrt(nrow(data))
logical
if TRUE
the quantile bins will overlap. Default value will be
FALSE
.
The color to use for the line charts
The fill color to use for the areas
If TRUE
, use a different color for each category
The number of column to be used in the layout
numeric
, the x marker.
numeric
, the quantile marker to use that is translated in a x value.
if TRUE
a rug is added to the plot
numeric
, the limits of the x-axis.
if TRUE
subsequent medians are connected.
Additional arguments to pass to the plot functions
A ggplot object with the plots
By highlighting and connecting the median values it creates a functional view of the data.
What is the (expected) median given a certain value of x
?
It qbin
s the x
variable and plots the medians of the qbins vs the other variables, thereby
creating a functional view of x
to the rest of the data,
calculating the statistics for each bin, hence the name funq_plot
.
Other conditional quantile plotting functions:
cond_barplot()
,
cond_boxplot()
,
cond_heatmap()
funq_plot(iris, "Sepal.Length", xmarker=5.5)
#> `overlap` not specified, using `overlap=FALSE`
#> `min_bin_size`=12, using `n=12`
# \donttest{
funq_plot(
iris,
x = "Sepal.Length",
xmarker=5.5,
overlap = TRUE
)
data("diamonds", package="ggplot2")
funq_plot(diamonds[1:7], "carat", xlim=c(0,2))
if (require(palmerpenguins)){
funq_plot(
penguins[1:7],
x = "body_mass_g",
xmarker=4650,
ncol = 3
)
}
#> `overlap` not specified, using `overlap=FALSE`
#> `min_bin_size`=18, using `n=19`
# }