diagram_to_df {TDApplied} | R Documentation |
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)
Arguments
d |
the output of a TDA/TDAstats homology calculation, like ripsDiag or |
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.
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.
Author(s)
Shael Brown - shaelebrown@gmail.com
Examples
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)
}
[Package TDApplied version 3.0.3 Index]