mk_lineplot | R Documentation |
mk_lineplot
takes a data frame as input and returns a function for
making lineplots with any continuous variables from the data frame on the y
axis, and any continuous or categorical variables from the data frame on the
x axis. The x variable often measures time, for example, years. When supplied
a categorical colorby variable, the output function will produce lineplots
where lines are colored differently according to the levels of the colorby
variable.
mk_lineplot(df)
df |
A data frame. |
function(xvar, yvar, colorby = "1", xorder = "alphanumeric",
is_y_pct = FALSE, pt_size = 1, linew = 0.7,
add_cnt_to_legend = TRUE, legend_title = colorby,
legend_pos = "right", font_size = 14)
xvar. String, name of a continuous or categorical variable for x-axis.
yvar. String, name of a continuous variable for y-axis.
colorby. String, name of a categorical variable for grouping and coloring the lines. Default = "1", meaning no such variable is supplied.
xorder. String, "alphanumeric", "ascend" or "descend". It specifies how categories are ordered on the x-axis. Default is "alphanumeric".
is_y_pct. logical, if TRUE, apply the percent format on y-axis. Default is FALSE, which means do not apply any special format to y-axis.
pt_size. Number, size of the points. Default = 1.
linew. Number, width of the line. Default = 0.7.
add_cnt_to_legend. Logical, when TRUE (default), it will show the number of non-missing records for each level in the colorby var.
legend_title. String, legend title. Default uses the name of the colorby variable.
legend_pos. String, legend position. Default = "right".
font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.
inst/examples/ex-mk_lineplot.R
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.