Create multi-panel plots of a data set grouped by one or two
grouping variables. Wrapper around facet_wrap
facet(p, facet.by, nrow = NULL, ncol = NULL, scales = "fixed",
short.panel.labs = TRUE, panel.labs = NULL,
panel.labs.background = list(color = NULL, fill = NULL),
panel.labs.font = list(face = NULL, color = NULL, size = NULL, angle =
NULL), panel.labs.font.x = panel.labs.font,
panel.labs.font.y = panel.labs.font, ...)a ggplot
character vector, of length 1 or 2, specifying grouping variables for faceting the plot into multiple panels. Should be in the data.
Number of rows and columns in the panel. Used only when the data is faceted by one grouping variable.
should axis scales of panels be fixed ("fixed", the default), free ("free"), or free in one dimension ("free_x", "free_y").
logical value. Default is TRUE. If TRUE, create short labels for panels by omitting variable names; in other words panels will be labelled only by variable grouping levels.
a list of one or two character vectors to modify facet panel labels. For example, panel.labs = list(sex = c("Male", "Female")) specifies the labels for the "sex" variable. For two grouping variables, you can use for example panel.labs = list(sex = c("Male", "Female"), rx = c("Obs", "Lev", "Lev2") ).
a list to customize the background of panel labels. Should contain the combination of the following elements:
color, linetype, size: background line color, type and size
fill: background fill color.
For example, panel.labs.background = list(color = "blue", fill = "pink", linetype = "dashed", size = 0.5).
a list of aestheics indicating the size (e.g.: 14), the face/style (e.g.: "plain", "bold", "italic", "bold.italic") and the color (e.g.: "red") and the orientation angle (e.g.: 45) of panel labels.
same as panel.labs.font but for only x and y direction, respectively.
not used
p <- ggboxplot(ToothGrowth, x = "dose", y = "len",
color = "supp")
print(p)
facet(p, facet.by = "supp")
Run the code above in your browser using DataLab