Learn R Programming

TDApplied (version 3.0.3)

diagram_to_df: Convert a TDA/TDAstats persistence diagram to a data frame.

Description

The output of homology calculations from the R packages TDA and TDAstats are not dataframes. This function converts these outputs into a data frame either for further usage in this package or for personalized analyses.

Usage

diagram_to_df(d)

Value

a 3-column data frame, with each row representing a topological feature. The first column is the feature dimension (a non-negative integer), the second column is the birth radius of the feature and the third column is the death radius.

Arguments

d

the output of a TDA/TDAstats homology calculation, like ripsDiag or calculate_homology.

Author

Shael Brown - shaelebrown@gmail.com

Details

If a diagram is constructed using a TDA function like ripsDiag with the `location` parameter set to true then the return value will ignore the location information.

Examples

Run this code

if(require("TDAstats"))
{
  # create a persistence diagram from a 2D Gaussian
  df = data.frame(x = rnorm(n = 20,mean = 0,sd = 1),y = rnorm(n = 20,mean = 0,sd = 1))

  # compute persistence diagram with calculate_homology from package TDAstats
  phom_TDAstats = TDAstats::calculate_homology(mat = df,dim = 0,threshold = 1)

  # convert to data frame
  phom_TDAstats_df = diagram_to_df(d = phom_TDAstats)
}

Run the code above in your browser using DataLab