build_df_cooc: Compute monthly co-occurrence matrix

View source: R/cooc.R

build_df_coocR Documentation

Compute monthly co-occurrence matrix

Description

Compute monthly co-occurrence matrix

Usage

build_df_cooc(
  df_ehr,
  uniq_codes = NULL,
  n_cores = 1,
  min_code_freq = 5,
  gc_before_parallel = TRUE
)

Arguments

df_ehr

Input data frame, monthly counts with columns Patient, Month, Parent_Code, Count

uniq_codes

Not required, useful for sql_cooc function

n_cores

Number of cores

min_code_freq

Filter matrix based on feature frequency

gc_before_parallel

Call garbage collector before computation

Value

Co-occurrence sparse matrix

Examples


df_ehr = data.frame(Month = c(1, 1, 1, 2, 2, 3, 3, 4, 4),
                    Patient = c(1, 1, 2, 1, 2, 1, 1, 3, 4),
                    Parent_Code = c('C1', 'C2', 'C2', 'C1', 'C1', 'C1', 'C2',
                                    'C3', 'C4'),
                    Count = 1:9)

spm_cooc = build_df_cooc(df_ehr)


nlpembeds documentation built on April 4, 2025, 4:41 a.m.