Learn R Programming

HVT (version 25.2.4)

plotStateTransition: Creating State Transition Plot

Description

This is the main function to create a state transition plot from a data frame. A state transition plot is a type of data visualization used to represent the changes or transitions in states over time for a given system. State refers to a particular condition or status of a cell at a specific point in time. Transition refers to the change of state for a cell from one condition to another over time.

Usage

plotStateTransition(
  df,
  sample_size = NULL,
  line_plot = NULL,
  cellid_column,
  time_column,
  v_intercept = NULL,
  time_periods = NULL
)

Value

A plotly object representing the state transition plot for the given data frame.

Arguments

df

Data frame. The Input data frame should contain two columns. Cell ID from scoreHVT function and time stamp of that dataset.

sample_size

Numeric. An integer indicating the fraction of the data frame to visualize in the plot. Default value is 0.2

line_plot

Logical. A logical value indicating to create a line plot. Default value is NULL.

cellid_column

Character. Name of the column containing cell IDs.

time_column

Character. Name of the column containing time stamps.

v_intercept

Numeric. A numeric value indicating the time stamp to draw a vertical line on the plot.

time_periods

List. A list of vectors, each containing start and end times for highlighting time periods.

Author

PonAnuReka Seenivasan <ponanureka.s@mu-sigma.com>, Vishwavani <vishwavani@mu-sigma.com>

Examples

Run this code
dataset <- data.frame(date = as.numeric(time(EuStockMarkets)),
DAX = EuStockMarkets[, "DAX"],
SMI = EuStockMarkets[, "SMI"],
CAC = EuStockMarkets[, "CAC"],
FTSE = EuStockMarkets[, "FTSE"])

hvt.results<- trainHVT(dataset,n_cells = 60, depth = 1, quant.err = 0.1,
                       distance_metric = "L1_Norm", error_metric = "max",
                       normalize = TRUE,quant_method = "kmeans")
scoring <- scoreHVT(dataset, hvt.results)
cell_id <- scoring$scoredPredictedData$Cell.ID
time_stamp <- dataset$date
dataset <- data.frame(cell_id, time_stamp)
plotStateTransition(dataset, sample_size = 1, cellid_column = "cell_id",time_column = "time_stamp")

Run the code above in your browser using DataLab