search_quotes: Search the quote database for a string or regex pattern

View source: R/search_quotes.R

search_quotesR Documentation

Search the quote database for a string or regex pattern

Description

This function takes a search pattern (or regular expression) and returns all quotes that match the pattern.

A convenient wrapper for search quotes that by default returns all quotes

Usage

search_quotes(
  search,
  ignore_case = TRUE,
  fuzzy = FALSE,
  fields = c("text", "source", "tags", "cite"),
  ...
)

search_text(search, fuzzy = FALSE, ...)

get_quotes(search = ".*", ...)

Arguments

search

A character string or regex pattern to search the database.

ignore_case

If TRUE, matching is done without regard to case.

fuzzy

If TRUE, use agrep to allow approximate matches to the search string.

fields

A character vector of the particular fields to search. The default is c("text","source","tags"). You can use the shortcut fields="all" to search all fields (including citation, url).

...

additional arguments passed to agrep to fine-tune fuzzy search parameters.

Value

A data frame (also with class 'statquote') object containing all quotes that match the search parameters.

A data frame (also with class 'statquote') object containing all quotes.

See Also

agrep, statquote.

Examples

search_quotes("^D") # regex to find all quotes that start with "D"
search_quotes("Tukey") # all quotes with "Tukey"
search_quotes("Turkey", fuzzy = TRUE) # fuzzy match

# to a data.frame
out <- search_quotes("bad data", fuzzy = TRUE)
as.data.frame(out)

search_text("omnibus")
qdb <- get_quotes()
nrow(qdb)
names(qdb)


statquotes documentation built on Oct. 10, 2023, 5:07 p.m.