Skip to content

Commit

Permalink
add metalite_table1_to_df
Browse files Browse the repository at this point in the history
  • Loading branch information
elong0527 committed Apr 11, 2024
1 parent b9ee9fa commit 5833010
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions R/metalite_table1.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,25 @@ metalite_table1_to_html <- function(x) {
attributes(x)$browsable_html <- NULL
print(x)
}


#' Convert to data frame
#'
#' @param x an output from `metalite_table1`.
#'
#' @return a data frame that contain the table from the html output and
#' a `.id` variable for variables.
#'
#' @export
#'
metalite_table1_to_df <- function(x) {

out <- lapply(x[[1]], function(.x){
tbl <- reactable_to_df(.x)
tbl$.id <- tbl[is.na(tbl[, 2]), "name_display"]
tbl
})
names(out) <- NULL
do.call(rbind, out)

}

0 comments on commit 5833010

Please sign in to comment.