PanelPlot {CluMP} | R Documentation |
Plot Micro-Panel (longitudinal) Data
Description
This function plots micro-panel (longitudinal) data from stored data.frame
or randomly generated panel data from GeneratePanel
function.
Usage
PanelPlot(
data,
formula = Y ~ Time,
group = "ID",
colour = NA,
mean_traj_all = FALSE,
mean_traj_group = FALSE,
show_legend = TRUE,
title = NULL,
x_title = NULL,
y_title = NULL
)
Arguments
data |
A data frame containing the variables named in |
formula |
A two-sided |
group |
A grouping factor variable (vector), i.e. single identifier for each (trajectory). |
colour |
Character, which is a variable's name in data. The trajectories are distinguished by colour according to this variable. |
mean_traj_all |
Logical scalar. It indicates whether to show mean overall trajectory. Default is FALSE. |
mean_traj_group |
Logical scalar. It indicates whether to show mean trajectory by group. Default is FALSE. |
show_legend |
Logical scalar. It indicates whether to show cluster legend. Default is TRUE. |
title |
String. Is an optional title for a plot. Otherwise no title will used. |
x_title |
String. Is an optional title for x axis. Otherwise variable name after ~ in |
y_title |
String. Is an optional title for y axis. Otherwise variable name before ~ in |
Value
Returns plot using package ggplot2.
Examples
set.seed(123)
dataMale <- GeneratePanel(n = 50, Param = ParamLinear, NbVisit = 10)
dataMale$Gender <- "M"
dataFemale <- GeneratePanel(n = 50, Param = ParamLinear, NbVisit = 10)
dataFemale$ID <- dataFemale$ID + 50
dataFemale$Gender <- "F"
data <- rbind(dataMale, dataFemale)
PanelPlot(data = data, formula = Y ~ Time, group = "ID", colour = "Gender")
PanelPlot(data = data, formula = Y ~ Time, group = "ID", colour = "Gender", mean_traj_all = TRUE)
PanelPlot(data = data, formula = Y ~ Time, group = "ID", colour = "Gender", mean_traj_group = TRUE)