Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistence homogy #24

Closed
lindasheila opened this issue Jul 1, 2021 · 1 comment
Closed

Persistence homogy #24

lindasheila opened this issue Jul 1, 2021 · 1 comment
Assignees

Comments

@lindasheila
Copy link

Dear All,

Please how do I read data from and external file to obtain the persistence homology:

The file has 4 columns: x y z. and it is in a certain directory let's say /home/linda/Destop/file.

Thank you!

@rrrlw rrrlw self-assigned this Jul 2, 2021
@rrrlw
Copy link
Owner

rrrlw commented Jul 2, 2021

I would use either read.table from the utils package or one of the read_* functions from the readr package. The exact function you use will depend on the format of your external data file. For instance, if you have a CSV, you would use one of the following blocks of code:

# code block using base R
library(TDAstats)

# read in data (change my_file.csv to your actual file name)
input_data <- read.csv("/home/linda/Desktop/file/my_file.csv")

# select the columns of interest and store in a new data frame
df_data <- input_data[, c("x", "y", "z")]

# convert that data frame to a numeric matrix
mat_data <- as.matrix(df_data)

# calculate persistent homology
homology_output <- calculate_homology(mat_data)
# code block using tidyverse
library(tidyverse)
library(TDAstats)

# read in data (change my_file.csv to your actual file name)
input_data <- read_csv("/home/linda/Desktop/file/my_file.csv")

# select the numeric columns of interest, convert to a matrix, and calculate persistent homology
homology_output <- input_data %>%
  select(x, y, z) %>%
  as.matrix() %>%
  calculate_homology()

Best of luck!

@rrrlw rrrlw closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants