R/get_book_ids.R

Defines functions get_book_ids

Documented in get_book_ids

#' Save Book IDs to a Text File
#'
#' This function retrieves the book_id values from the input_data and saves them to a specified text file.
#'
#' @param input_data A data frame containing a column named book_id.
#' @param file_name A string specifying the name of the text file to save the book_id values.
#' @return No return value, the function writes the book_id values to a text file.
#' @export
#' @examples
#' # Create sample data
#' books <- data.frame(title = c("Hamlet", "The Hunger Games", "Jane Eyre"),
#'                     book_id = c("1420", "2767052", "10210")
#'                     )
#' # Create a temporary file path
#' temp_file <- file.path(tempdir(), "bookids.txt")
#'
#' # Run the function
#' get_book_ids(books, temp_file)
#'
#' # Clean up: remove the temporary file
#' file.remove(temp_file)

get_book_ids <- function(input_data, file_name) {

  # Retrieve the book_id values
  book_ids <- input_data$book_id

  # Write the book_id values to a text file
  writeLines(book_ids, file_name)

  message("Book IDs saved to ", file_name)
}

Try the Goodreader package in your browser

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

Goodreader documentation built on Oct. 30, 2024, 9:11 a.m.