knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This notebook shows how to use the monad ERTMon provided by this package.
Clear all R-session definitions:
rm(list=ls())
Load the package from the GitHub repository:
library(devtools) install_github("antononcube/ERTMon-R") library(ERTMon)
dirName <- if( grepl("vignettes", getwd()) ) { file.path( getwd(), "..", "data", "FakeData") } else { file.path( getwd(), "data", "FakeData")} dirName
Here we read the event records data and display a sample of it.
fakeEventRecords <- read.csv( file = file.path( dirName, "eventRecords.csv"), stringsAsFactors = FALSE) head(fakeEventRecords)
Here we read the entity attributes data and display a sample of it.
fakeEntityAttributes <- read.csv( file = file.path( dirName, "entityAttributes.csv"), stringsAsFactors = FALSE) fakeEntityAttributes
Here we read the computation specification.
fakeCompSpec <- read.csv( file = file.path( dirName, "computationSpecification.csv"), stringsAsFactors = FALSE) fakeCompSpec
With the main pipeline we take event records data and transform that data into a feature matrix.
Each row of the feature matrix corresponds to an entity; each column to a feature.
A feature is combination of a variable name, aggregation function name, and a time cell index.
Initialize the monad and set the event records, entity attributes, and computation specification.
ertmon1 <- ERTMonUnit() %>% ERTMonSetEventRecords( fakeEventRecords ) %>% ERTMonSetEntityAttributes( fakeEntityAttributes ) %>% ERTMonSetComputationSpecification( fakeCompSpec )
The pipeline function that does the heavy lifting.
ertmon1 <- ertmon1 %>% ERTMonProcessEventRecords()
Here we get the feature sub-matrices. Each feature sub-matrix corresponds to a variable and an aggregation function name. (Derived from the computation specification.)
smats <- ertmon1 %>% ERTMonTakeContingencyMatrices() names(smats)
smats[["HR.Mean"]][1:12,]
image(ertmon1 %>% ERTMonTakeFeatureMatrix)
ertmon1 %>% ERTMonTakeTimeCellsInterpretation
ertmon1 %>% ERTMonExportToCSVFeatureMatrix( fileName = file.path( dirName, "featureMatrix.csv") )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.