suppressPackageStartupMessages({
  library(kableExtra)
  library(rtrackr)
  library(networkD3)
})

Setting up

Below is an example of a more complicated workflow, starting from a simple input file, to be used as an example of a full rtrackr workflow.

We will define and log a simple dataframe for this example. For more information, please see getting started and summarising data.

df <- data.frame(a = c('a', 'b', 'c'), b = c(1, 2, 3))

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

trackr_dir <- '~/Documents/Personal/trackr_dev/trackr_dir'

#setup a new trackr
df <- trackr_new(df, trackr_dir = trackr_dir, timepoint_message = 'Start', suppress_success = TRUE)

Workflow

#make some change to the data 
df <- df %>% dplyr::mutate(b = b + 1)

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'Change point #1', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

#repeat for subsequent processing steps
df <- df %>% dplyr::mutate(b = b + 300)

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'Change point #2', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

#splitting a single record into multiples
df <- rbind(df, df %>% dplyr::mutate(b = b -300))

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'Dividing rows', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

#summarising data
df <- df %>% dplyr::group_by(a)

df <- trackr_summarise(df, n = dplyr::n())

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'Summarising rows', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

df <- df %>% dplyr::mutate(n = n**runif(3))

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'Further Processing', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

df <- rbind(df, df %>% dplyr::mutate(n = n -60), df %>% dplyr::mutate(n = n * 2), df %>% dplyr::mutate(n = n * 56))

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'Really messing with things', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

df <- df %>% dplyr::mutate(n = n + 1)

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'added 1', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

df <- df %>% dplyr::group_by(a) %>% 
  trackr_summarise(n =  dplyr::n())

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'grouped', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

df <- df %>% dplyr::mutate(n = n + 2000)

df <- trackr_timepoint(df, trackr_dir = trackr_dir, timepoint_message = 'added 2000', suppress_success = TRUE)

Details

kable(df) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"))

Results

Inspect the full processing chain of a single record with trackr_lineage() and trackr_network(). For more information, please see getting started.

target_id <- df$trackr_id[1]
trackr_lineage(target_id, trackr_dir)

lineage_fn <- paste0(trackr_dir, '/', target_id, '_lineage.json')

trackr_network(lineage_fn)

Clean up

clean_trackr_dir(trackr_dir)

Article by Hamish Gibbs r Sys.time(). To report a problem with this package, please create an issue on GitHub.



hamishgibbs/rtrackr documentation built on June 25, 2020, 8:16 p.m.