Closed zenalapp closed 2 years ago
A function would probably be better, but we could also just include in vignette.
Example code (there might be a more elegant way):
# isolate_dat contains columns with isolate_id and collection_date date_info <- isolate_dat %>% dplyr::select(isolate_id, collection_date) date_diff_mat <- sapply(date_info$isolate_id, function(x){ sapply(date_info$isolate_id, function(y){ as.numeric(abs(date_info$collection_date[date_info$isolate_id == x] - date_info$collection_date[date_info$isolate_id == y])) }) }) date_diff_long <- regentrans::make_long_form(date_diff_mat, col_names = c('isolate1', 'isolate2', 'days_diff'), remove_zeros = FALSE) %>% dplyr::filter(isolate1 != isolate2)
Done
A function would probably be better, but we could also just include in vignette.
Example code (there might be a more elegant way):