From ce60b2344aefa55dc9b02b28c3d21a02e53dfc6a Mon Sep 17 00:00:00 2001 From: laresbernardo Date: Wed, 12 Apr 2023 15:39:38 -0500 Subject: [PATCH] feat: new gpt_history() and markdown2df() functions --- NAMESPACE | 2 ++ R/cache.R | 11 +++++--- R/chatgpt.R | 63 +++++++++++++++++++++++++++++++----------- R/other_functions.R | 19 +++++++++++++ R/zzz.R | 12 +++++++- man/autoline.Rd | 1 + man/bind_files.Rd | 1 + man/bring_api.Rd | 1 + man/cache_write.Rd | 12 +++++--- man/db_download.Rd | 1 + man/db_upload.Rd | 1 + man/export_plot.Rd | 1 + man/export_results.Rd | 1 + man/files_functions.Rd | 1 + man/font_exists.Rd | 1 + man/formatColoured.Rd | 1 + man/format_string.Rd | 1 + man/get_credentials.Rd | 1 + man/glued.Rd | 1 + man/gpt_ask.Rd | 15 ++++++++-- man/grepm.Rd | 1 + man/h2o_selectmodel.Rd | 1 + man/haveInternet.Rd | 1 + man/image_metadata.Rd | 1 + man/importxlsx.Rd | 1 + man/ip_data.Rd | 1 + man/json2vector.Rd | 1 + man/list_cats.Rd | 1 + man/listfiles.Rd | 1 + man/mail_send.Rd | 1 + man/markdown2df.Rd | 56 +++++++++++++++++++++++++++++++++++++ man/move_files.Rd | 1 + man/msplit.Rd | 1 + man/myip.Rd | 1 + man/quiet.Rd | 1 + man/read.file.Rd | 1 + man/statusbar.Rd | 1 + man/tic.Rd | 1 + man/try_require.Rd | 1 + man/updateLares.Rd | 1 + man/warnifnot.Rd | 1 + man/what_size.Rd | 1 + 42 files changed, 196 insertions(+), 28 deletions(-) create mode 100644 man/markdown2df.Rd diff --git a/NAMESPACE b/NAMESPACE index 69f15bf34..98bbfd649 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -92,6 +92,7 @@ export(gpt_classify) export(gpt_convert) export(gpt_extract) export(gpt_format) +export(gpt_history) export(gpt_table) export(gpt_tag) export(gpt_translate) @@ -131,6 +132,7 @@ export(loglossBinary) export(mae) export(mail_send) export(mape) +export(markdown2df) export(missingness) export(model_metrics) export(model_preprocess) diff --git a/R/cache.R b/R/cache.R index 673b402be..00bcf606e 100644 --- a/R/cache.R +++ b/R/cache.R @@ -18,6 +18,7 @@ #' if the cache should be used to proceed or ignored; when writing, (interactive) #' ask the user if the cache should be overwritten. Note that you can only ask for #' one cache file at a time because vectors are concatenated. +#' @param ... Additional parameters. #' @return \code{cache_write}. No return value, called for side effects. #' @examples #' x <- list(a = 1, b = 2:4) @@ -31,7 +32,8 @@ cache_write <- function(data, base = "temp", cache_dir = getOption("LARES_CACHE_DIR"), ask = FALSE, - quiet = FALSE) { + quiet = FALSE, + ...) { if (is.null(getOption("LARES_CACHE_DIR"))) { cache_dir <- tempdir() } @@ -67,7 +69,8 @@ cache_write <- function(data, cache_read <- function(base, cache_dir = getOption("LARES_CACHE_DIR"), ask = FALSE, - quiet = FALSE) { + quiet = FALSE, + ...) { base <- paste(base, collapse = ".") if (left(base, 12) != "lares_cache_") base <- paste0("lares_cache_", base) if (right(base, 4) == ".RDS") base <- gsub("\\.RDS", "", base) @@ -95,7 +98,7 @@ cache_read <- function(base, #' @rdname cache_write #' @return \code{cache_exists}. Boolean. Result of \code{base} existence. #' @export -cache_exists <- function(base = NULL, cache_dir = getOption("LARES_CACHE_DIR")) { +cache_exists <- function(base = NULL, cache_dir = getOption("LARES_CACHE_DIR"), ...) { if (is.null(getOption("LARES_CACHE_DIR"))) { cache_dir <- tempdir() } @@ -119,7 +122,7 @@ cache_exists <- function(base = NULL, cache_dir = getOption("LARES_CACHE_DIR")) #' @rdname cache_write #' @return \code{cache_clear}. Invisible vector containing cache file names removed. #' @export -cache_clear <- function(cache_dir = getOption("LARES_CACHE_DIR"), quiet = FALSE) { +cache_clear <- function(cache_dir = getOption("LARES_CACHE_DIR"), quiet = FALSE, ...) { if (is.null(cache_dir)) cache_dir <- tempdir() files <- list.files(cache_dir) caches <- files[startsWith(files, "lares_cache_")] diff --git a/R/chatgpt.R b/R/chatgpt.R index 25cc773a0..570afc8b7 100644 --- a/R/chatgpt.R +++ b/R/chatgpt.R @@ -1,8 +1,14 @@ +hist_ask <- "GPT_HIST_ASK" +hist_reply <- "GPT_HIST_REPLY" + #################################################################### #' ChatGPT API Interaction with R #' #' This function lets the user ask ChatGPT via its API, and returns -#' the rendered reply. +#' the rendered reply. There are a couple of specific verbs (functions) with a +#' preset prompt to help fetch the data in specific formats. We also +#' store the prompts and replies in current session with their respective +#' time-stamps so user can gather historical results. #' #' @family API #' @inheritParams db_download @@ -49,14 +55,25 @@ #' gpt_translate( #' rep("I love you with all my heart", 5), #' language = c("spanish", "chinese", "japanese", "russian", "german")) +#' +#' # Now let's read the historical prompts and replies from current session +#' gpt_history() #' } #' @export gpt_ask <- function(ask, - secret_key = get_credentials()$openai$secret_key, - url = "https://api.openai.com/v1/chat/completions", - model = "gpt-3.5-turbo", - quiet = FALSE, ...) { + secret_key = get_credentials()$openai$secret_key, + url = Sys.getenv("LARES_GPT_URL"), + model = Sys.getenv("LARES_GPT_MODEL"), + quiet = FALSE, ...) { + ts <- Sys.time() if (length(ask) > 1) ask <- paste(ask, collapse = " + ") + # Save historical questions + if (cache_exists(hist_ask)){ + cache <- cache_read(hist_ask, quiet = TRUE, ...) + cache <- rbind(cache, data.frame(ts = ts, prompt = ask)) + } else cache <- data.frame(ts = ts, prompt = ask) + cache_write(distinct(cache), hist_ask, quiet = TRUE, ...) + # Ask ChatGPT using their API response <- POST( url = url, add_headers(Authorization = paste("Bearer", secret_key)), @@ -74,9 +91,29 @@ gpt_ask <- function(ask, if ("error" %in% names(ret)) warning(ret$error$message) if ("message" %in% names(ret$choices[[1]]) & !quiet) cat(stringr::str_trim(ret$choices[[1]]$message$content)) + # Save historical answers + if (cache_exists(hist_ask)){ + cache <- cache_read(hist_reply, quiet = TRUE, ...) + cache <- rbind(cache, data.frame(ts = ts, reply = ret)) + } else cache <- data.frame(ts = ts, prompt = ret) + cache_write(distinct(cache), hist_reply, quiet = TRUE, ...) return(invisible(ret)) } +#' @rdname gpt_ask +#' @export +gpt_history <- function() { + asks <- cache_read(hist_ask, quiet = TRUE) + if (!is.null(asks)) { + replies <- cache_read(hist_reply, quiet = TRUE) + hist <- as_tibble(left_join(asks, replies, by = "ts")) %>% + select(.data$ts, .data$prompt, contains("message.content"), everything()) + return(hist) + } else { + warning("No historical prompts nor replies registered yet") + } +} + #' @param x Vector. List items you wish to process #' @param categories,tags Vector. List of possible categories/tags to consider. #' @rdname gpt_ask @@ -160,15 +197,9 @@ gpt_prompt_builder <- function(type = "category", cols = c("item", type), x, y) gpt_markdown2df <- function(resp) { if ("message" %in% names(resp$choices[[1]])) { - df <- resp$choices[[1]]$message$content - # Convert markdown to data.frame - df <- removenacols(read.table(text = df, sep = "|", header = TRUE, strip.white = TRUE, quote="\"")) - # Get rid of potential first row with all values set as --- or :--- - if (all(stringr::str_split(df[1, 1], "-")[[1]] == "")) df <- df[-1, ] - if (substr(df[1, 1], 1, 4) == ":---") df <- df[-1, ] - rownames(df) <- NULL - df <- as_tibble(df) - attr(df, "response") <- resp - return(df) - } else return(resp) + resp <- resp$choices[[1]]$message$content + } + df <- try(markdown2df(resp)) + attr(df, "response") <- df + return(df) } diff --git a/R/other_functions.R b/R/other_functions.R index 908465e3e..67316f8e7 100644 --- a/R/other_functions.R +++ b/R/other_functions.R @@ -970,3 +970,22 @@ warnifnot <- function(...) if (!isTRUE(...)) warning(paste(deparse(...), "is not what_size <- function(x, units = "Mb", ...) { format(object.size(x), units = units, ...) } + +#################################################################### +#' Convert markdown string tables to data.frame +#' +#' @family Tools +#' @param text Character. Markdown text representing a table. +#' @examples +#' txt <- "| Item | Value |\n|------|-------|\n| 50C | 122F |\n| 300K | 80.33F |" +#' markdown2df(txt) +#' @export +markdown2df <- function(text) { + df <- removenacols(read.table(text = text, sep = "|", header = TRUE, strip.white = TRUE, quote="\"")) + # Get rid of potential first row with all values set as --- or :--- + if (all(stringr::str_split(df[1, 1], "-")[[1]] == "")) df <- df[-1, ] + if (substr(df[1, 1], 1, 4) == ":---") df <- df[-1, ] + rownames(df) <- NULL + df <- as_tibble(df) + return(df) +} diff --git a/R/zzz.R b/R/zzz.R index 0a6e2e19a..19bc1a1e7 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,5 +1,4 @@ .onLoad <- function(libname, pkgname) { - # Old options: lares.font, lares.formatNum, lares.lang Sys.setenv( # So user can set another font be default on theme_lares() "LARES_FONT" = if (Sys.getenv("LARES_FONT") != "") { @@ -24,6 +23,17 @@ Sys.getenv("LARES_LANG") } else { "es" + }, + # ChatGPT Default values + "LARES_GPT_MODEL" = if (Sys.getenv("LARES_GPT_MODEL") != "") { + Sys.getenv("LARES_GPT_MODEL") + } else { + "gpt-3.5-turbo" + }, + "LARES_GPT_URL" = if (Sys.getenv("LARES_GPT_URL") != "") { + Sys.getenv("LARES_GPT_URL") + } else { + "https://api.openai.com/v1/chat/completions" } ) options( diff --git a/man/autoline.Rd b/man/autoline.Rd index 0ddb1cb90..cecb7d54d 100644 --- a/man/autoline.Rd +++ b/man/autoline.Rd @@ -60,6 +60,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/bind_files.Rd b/man/bind_files.Rd index 866b72afd..05a7de168 100644 --- a/man/bind_files.Rd +++ b/man/bind_files.Rd @@ -40,6 +40,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/bring_api.Rd b/man/bring_api.Rd index 6c775ca0c..ed09be0aa 100644 --- a/man/bring_api.Rd +++ b/man/bring_api.Rd @@ -43,6 +43,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/cache_write.Rd b/man/cache_write.Rd index 2963a07bd..37fc5e0ce 100644 --- a/man/cache_write.Rd +++ b/man/cache_write.Rd @@ -12,19 +12,21 @@ cache_write( base = "temp", cache_dir = getOption("LARES_CACHE_DIR"), ask = FALSE, - quiet = FALSE + quiet = FALSE, + ... ) cache_read( base, cache_dir = getOption("LARES_CACHE_DIR"), ask = FALSE, - quiet = FALSE + quiet = FALSE, + ... ) -cache_exists(base = NULL, cache_dir = getOption("LARES_CACHE_DIR")) +cache_exists(base = NULL, cache_dir = getOption("LARES_CACHE_DIR"), ...) -cache_clear(cache_dir = getOption("LARES_CACHE_DIR"), quiet = FALSE) +cache_clear(cache_dir = getOption("LARES_CACHE_DIR"), quiet = FALSE, ...) } \arguments{ \item{data}{Object} @@ -44,6 +46,8 @@ ask the user if the cache should be overwritten. Note that you can only ask for one cache file at a time because vectors are concatenated.} \item{quiet}{Boolean. Keep quiet? If not, message will be shown.} + +\item{...}{Additional parameters.} } \value{ \code{cache_write}. No return value, called for side effects. diff --git a/man/db_download.Rd b/man/db_download.Rd index 8b23773c6..104a527fb 100644 --- a/man/db_download.Rd +++ b/man/db_download.Rd @@ -74,6 +74,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/db_upload.Rd b/man/db_upload.Rd index a598c81d2..aa75c79bb 100644 --- a/man/db_upload.Rd +++ b/man/db_upload.Rd @@ -55,6 +55,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/export_plot.Rd b/man/export_plot.Rd index 97f68487e..031679109 100644 --- a/man/export_plot.Rd +++ b/man/export_plot.Rd @@ -73,6 +73,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/export_results.Rd b/man/export_results.Rd index 3a6b4c935..bbd3730b2 100644 --- a/man/export_results.Rd +++ b/man/export_results.Rd @@ -83,6 +83,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/files_functions.Rd b/man/files_functions.Rd index 3976504df..94d96cf53 100644 --- a/man/files_functions.Rd +++ b/man/files_functions.Rd @@ -57,6 +57,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/font_exists.Rd b/man/font_exists.Rd index a11dcb449..ec4ea44e9 100644 --- a/man/font_exists.Rd +++ b/man/font_exists.Rd @@ -46,6 +46,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/formatColoured.Rd b/man/formatColoured.Rd index 876875c0a..c4bd278cc 100644 --- a/man/formatColoured.Rd +++ b/man/formatColoured.Rd @@ -55,6 +55,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/format_string.Rd b/man/format_string.Rd index b056e47e9..8eb5dbb82 100644 --- a/man/format_string.Rd +++ b/man/format_string.Rd @@ -119,6 +119,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/get_credentials.Rd b/man/get_credentials.Rd index 873e32a6e..4c22bca1f 100644 --- a/man/get_credentials.Rd +++ b/man/get_credentials.Rd @@ -106,6 +106,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/glued.Rd b/man/glued.Rd index 228e487f5..3b8832839 100644 --- a/man/glued.Rd +++ b/man/glued.Rd @@ -79,6 +79,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/gpt_ask.Rd b/man/gpt_ask.Rd index fbde36140..c5c59455a 100644 --- a/man/gpt_ask.Rd +++ b/man/gpt_ask.Rd @@ -2,6 +2,7 @@ % Please edit documentation in R/chatgpt.R \name{gpt_ask} \alias{gpt_ask} +\alias{gpt_history} \alias{gpt_classify} \alias{gpt_tag} \alias{gpt_extract} @@ -14,12 +15,14 @@ gpt_ask( ask, secret_key = get_credentials()$openai$secret_key, - url = "https://api.openai.com/v1/chat/completions", - model = "gpt-3.5-turbo", + url = Sys.getenv("LARES_GPT_URL"), + model = Sys.getenv("LARES_GPT_MODEL"), quiet = FALSE, ... ) +gpt_history() + gpt_classify(x, categories, quiet = TRUE, ...) gpt_tag(x, tags, quiet = TRUE, ...) @@ -64,7 +67,10 @@ currency ISO code, ISO, Fahrenheit, etc.} } \description{ This function lets the user ask ChatGPT via its API, and returns -the rendered reply. +the rendered reply. There are a couple of specific verbs (functions) with a +preset prompt to help fetch the data in specific formats. We also +store the prompts and replies in current session with their respective +time-stamps so user can gather historical results. } \examples{ \dontrun{ @@ -101,6 +107,9 @@ gpt_table("5 random people's address in South America, email, phone, age between gpt_translate( rep("I love you with all my heart", 5), language = c("spanish", "chinese", "japanese", "russian", "german")) + +# Now let's read the historical prompts and replies from current session +gpt_history() } } \seealso{ diff --git a/man/grepm.Rd b/man/grepm.Rd index 6c625f27a..bb5cf5c73 100644 --- a/man/grepm.Rd +++ b/man/grepm.Rd @@ -62,6 +62,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/h2o_selectmodel.Rd b/man/h2o_selectmodel.Rd index f9b153ba7..2a5572314 100644 --- a/man/h2o_selectmodel.Rd +++ b/man/h2o_selectmodel.Rd @@ -62,6 +62,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/haveInternet.Rd b/man/haveInternet.Rd index 0f3147d87..2ccd68c4e 100644 --- a/man/haveInternet.Rd +++ b/man/haveInternet.Rd @@ -42,6 +42,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/image_metadata.Rd b/man/image_metadata.Rd index b4d70918a..a1cf09f72 100644 --- a/man/image_metadata.Rd +++ b/man/image_metadata.Rd @@ -39,6 +39,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/importxlsx.Rd b/man/importxlsx.Rd index 4edda3cd5..7e0b66e59 100644 --- a/man/importxlsx.Rd +++ b/man/importxlsx.Rd @@ -40,6 +40,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/ip_data.Rd b/man/ip_data.Rd index ad1392bde..2b3254106 100644 --- a/man/ip_data.Rd +++ b/man/ip_data.Rd @@ -51,6 +51,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/json2vector.Rd b/man/json2vector.Rd index 9532f5b4e..a866cb2b9 100644 --- a/man/json2vector.Rd +++ b/man/json2vector.Rd @@ -44,6 +44,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/list_cats.Rd b/man/list_cats.Rd index b16b80acb..8afd10862 100644 --- a/man/list_cats.Rd +++ b/man/list_cats.Rd @@ -50,6 +50,7 @@ Other Tools: \code{\link{json2vector}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/listfiles.Rd b/man/listfiles.Rd index 51a872ad9..69acf54b8 100644 --- a/man/listfiles.Rd +++ b/man/listfiles.Rd @@ -59,6 +59,7 @@ Other Tools: \code{\link{json2vector}()}, \code{\link{list_cats}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/mail_send.Rd b/man/mail_send.Rd index 997284041..b1ef46162 100644 --- a/man/mail_send.Rd +++ b/man/mail_send.Rd @@ -81,6 +81,7 @@ Other Tools: \code{\link{json2vector}()}, \code{\link{list_cats}()}, \code{\link{listfiles}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/markdown2df.Rd b/man/markdown2df.Rd new file mode 100644 index 000000000..e5e05a6b7 --- /dev/null +++ b/man/markdown2df.Rd @@ -0,0 +1,56 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/other_functions.R +\name{markdown2df} +\alias{markdown2df} +\title{Convert markdown string tables to data.frame} +\usage{ +markdown2df(text) +} +\arguments{ +\item{text}{Character. Markdown text representing a table.} +} +\description{ +Convert markdown string tables to data.frame +} +\examples{ +txt <- "| Item | Value |\n|------|-------|\n| 50C | 122F |\n| 300K | 80.33F |" +markdown2df(txt) +} +\seealso{ +Other Tools: +\code{\link{autoline}()}, +\code{\link{bind_files}()}, +\code{\link{bring_api}()}, +\code{\link{db_download}()}, +\code{\link{db_upload}()}, +\code{\link{export_plot}()}, +\code{\link{export_results}()}, +\code{\link{files_functions}()}, +\code{\link{font_exists}()}, +\code{\link{formatColoured}()}, +\code{\link{formatHTML}()}, +\code{\link{get_credentials}()}, +\code{\link{glued}()}, +\code{\link{grepm}()}, +\code{\link{h2o_selectmodel}()}, +\code{\link{haveInternet}()}, +\code{\link{image_metadata}()}, +\code{\link{importxlsx}()}, +\code{\link{ip_data}()}, +\code{\link{json2vector}()}, +\code{\link{list_cats}()}, +\code{\link{listfiles}()}, +\code{\link{mail_send}()}, +\code{\link{move_files}()}, +\code{\link{msplit}()}, +\code{\link{myip}()}, +\code{\link{quiet}()}, +\code{\link{read.file}()}, +\code{\link{statusbar}()}, +\code{\link{tic}()}, +\code{\link{try_require}()}, +\code{\link{updateLares}()}, +\code{\link{warnifnot}()}, +\code{\link{what_size}()} +} +\concept{Tools} diff --git a/man/move_files.Rd b/man/move_files.Rd index eb1f7be75..65027818a 100644 --- a/man/move_files.Rd +++ b/man/move_files.Rd @@ -44,6 +44,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{msplit}()}, \code{\link{myip}()}, \code{\link{quiet}()}, diff --git a/man/msplit.Rd b/man/msplit.Rd index bdabe3f75..761ddf3e0 100644 --- a/man/msplit.Rd +++ b/man/msplit.Rd @@ -72,6 +72,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{myip}()}, \code{\link{quiet}()}, diff --git a/man/myip.Rd b/man/myip.Rd index 10048fd6c..c7c8e819a 100644 --- a/man/myip.Rd +++ b/man/myip.Rd @@ -42,6 +42,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{quiet}()}, diff --git a/man/quiet.Rd b/man/quiet.Rd index ae3d14641..964906d16 100644 --- a/man/quiet.Rd +++ b/man/quiet.Rd @@ -43,6 +43,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/read.file.Rd b/man/read.file.Rd index 1009870f6..d418c5cf2 100644 --- a/man/read.file.Rd +++ b/man/read.file.Rd @@ -48,6 +48,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/statusbar.Rd b/man/statusbar.Rd index 4d01621b2..c50bf712b 100644 --- a/man/statusbar.Rd +++ b/man/statusbar.Rd @@ -75,6 +75,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/tic.Rd b/man/tic.Rd index 9582743e5..eb36f9b79 100644 --- a/man/tic.Rd +++ b/man/tic.Rd @@ -83,6 +83,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/try_require.Rd b/man/try_require.Rd index 547d5d9b3..2289cd250 100644 --- a/man/try_require.Rd +++ b/man/try_require.Rd @@ -58,6 +58,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/updateLares.Rd b/man/updateLares.Rd index d75e3eec6..e8c8766db 100644 --- a/man/updateLares.Rd +++ b/man/updateLares.Rd @@ -49,6 +49,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/warnifnot.Rd b/man/warnifnot.Rd index 6ca830702..ee77c945c 100644 --- a/man/warnifnot.Rd +++ b/man/warnifnot.Rd @@ -43,6 +43,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()}, diff --git a/man/what_size.Rd b/man/what_size.Rd index c3e76af73..4a13884d4 100644 --- a/man/what_size.Rd +++ b/man/what_size.Rd @@ -47,6 +47,7 @@ Other Tools: \code{\link{list_cats}()}, \code{\link{listfiles}()}, \code{\link{mail_send}()}, +\code{\link{markdown2df}()}, \code{\link{move_files}()}, \code{\link{msplit}()}, \code{\link{myip}()},