tests/testthat/_snaps/lang-help.md

Interaction with LLM works

Code
  lang_help("llm_classify", "mall", lang = "spanish", type = "text")
Message
  v lang - Translation complete
Output
  _C_a_t_e_g_o_r_i_z_e _d_a_t_a _a_s _o_n_e _o_f _o_p_t_i_o_n_s _g_i_v_e_n

  _D_e_s_c_r_i_p_t_i_o_n:

       Use a Large Language Model (LLM) to classify the provided text as
       one of the options provided via the 'labels' argument.

  _U_s_a_g_e:

       llm_classify(
         .data,
         col,
         labels,
         pred_name = ".classify",
         additional_prompt = ""
       )

       llm_vec_classify(x, labels, additional_prompt = "", preview = FALSE)

  _A_r_g_u_m_e_n_t_s:

     .data: A 'data.frame' or 'tbl' object that contains the text to be
            analyzed

       col: The name of the field to analyze, supports 'tidy-eval'

    labels: A character vector with at least 2 labels to classify the
            text as

  pred_name: A character vector with the name of the new column where the
            prediction will be placed

  additional_prompt: Inserts this text into the prompt sent to the LLM

         x: A vector that contains the text to be analyzed

   preview: It returns the R call that would have been used to run the
            prediction. It only returns the first record in 'x'. Defaults
            to 'FALSE' Applies to vector function only.

  _V_a_l_u_e:

       'llm_classify' returns a 'data.frame' or 'tbl' object.
       'llm_vec_classify' returns a vector that is the same length as
       'x'.

  _E_x_a_m_p_l_e_s:

       library(mall)

       data("reviews")

       llm_use("ollama", "llama3.2", seed = 100, .silent = TRUE)

       llm_classify(reviews, review, c("appliance", "computer"))

       # Use 'pred_name' to customize the new column's name
       llm_classify(
         reviews,
         review,
         c("appliance", "computer"),
         pred_name = "prod_type"
       )

       # Pass custom values for each classification
       llm_classify(reviews, review, c("appliance" ~ 1, "computer" ~ 2))

       # For character vectors, instead of a data frame, use this function
       llm_vec_classify(
         c("this is important!", "just whenever"),
         c("urgent", "not urgent")
       )

       # To preview the first call that will be made to the downstream R function
       llm_vec_classify(
         c("this is important!", "just whenever"),
         c("urgent", "not urgent"),
         preview = TRUE
       )
Code
  lang_help("llm_classify", "mall", lang = "english", type = "text")
Condition
  Error in `lang_help()`:
  ! Language already set to English, use `help()`
Code
  lang_help("nothere", lang = "spanish", type = "text")
Condition
  Error in `rd_find()`:
  ! Could not find `nothere`
  i Tip: Make sure the containing package is loaded, and the topic is spelled correctly
Code
  lang_help("nothere", "notpkg", lang = "spanish", type = "text")
Condition
  Error in `rd_find()`:
  ! Package `notpkg` not found
  i Tip: Make sure package name is spelled correctly
Code
  lang_help("nothere", "mall", lang = "spanish", type = "text")
Condition
  Error in `rd_find()`:
  ! `nothere` could not be found in `mall`
  i Tip: Make sure both are spelled correctly


Try the lang package in your browser

Any scripts or data that you put into this service are public.

lang documentation built on June 5, 2026, 5:08 p.m.