Closed lindasheila closed 3 years ago
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!
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!