| left_joinr | R Documentation |
This function is a wrapper around dplyr::left_join. Additional actions are performed on the background to log the information of the join action, and info regarding the step is printed.
left_joinr(x, y, by = NULL, ..., comment = "", keepids = FALSE)
x, y |
a pair of data frames used for joining |
by |
character vector of variables to join by |
... |
additional arguments passed to dplyr::left_join |
comment |
information for the reason of merging |
keepids |
logical indicating if merge identifiers should be available in output data (for checking purposes) |
The function can be used to keep track of records that are available after a join in the data management process. Joining of data could lead to unexpected results, e.g. creation of cartesian product or loosing data. Therefore it is important to know what the result of a join step is. Every time the function is used it creates a records in in a log file which can be used in the documentation.
a joined data frame
Richard Hooijmaijers
dplyr::left_join
dose <- data.frame(Subject = unique(Theoph$Subject),
dose = sample(1:3,length(unique(Theoph$Subject)),
replace = TRUE))
dose2 <- dose[dose$Subject%in%1:6,]
# Preferred to explicitly list by
dat1 <- left_joinr(Theoph, dose, by="Subject")
# The base R pipe is preferred for better logging of source data
dat2 <- Theoph |> left_joinr(dose, by="Subject")
# Avoid long pipes before function for readability in log. e.g dont:
dat3 <- Theoph |> dplyr::mutate(ID=3) |> dplyr::bind_cols(X=3) |>
left_joinr(dose, by="Subject")
# Show what is being logged
get_log()$joinr_nfo
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.