sim_read reads similarity matrix.

sim_read(input, file_format = "parquet")

Arguments

input

character string specifying the input filename or directory.

file_format

character string specify file format. This must be one of csv or parquet(default).

Value

metric_sim object.

Examples

suppressMessages(suppressWarnings(library(magrittr)))
population <- tibble::tibble(
  Metadata_group = sample(c("a", "b"), 4, replace = TRUE),
  x = rnorm(4),
  y = x + rnorm(4) / 100,
  z = y + rnorm(4) / 1000
)
tmpdir <- tempdir()
tmpfile_prefix <- file.path(tmpdir, "test")
tmpfile_parquet <- file.path(tmpdir, "test.pqrquet")
sim_df <- sim_calculate(population, method = "pearson")
sim_df %>% sim_write(tmpfile_prefix, file_format = "csv")
#> NULL
sim_df_csv <- sim_read(tmpfile_prefix, file_format = "csv")
sim_df %>% sim_write(tmpfile_parquet)
#> NULL
sim_df_parquet1 <- sim_read(tmpfile_parquet)
sim_df %>% arrow::write_parquet(tmpfile_parquet)
sim_df_parquet2 <- arrow::read_parquet(tmpfile_parquet)
all(sim_df_parquet1 == sim_df_parquet2)
#> [1] TRUE
all(sim_df_parquet1 == sim_df_csv)
#> [1] FALSE