R/pref.R

Defines functions is_pref pref_data pref

Documented in is_pref pref_data

pref <- function(data) {
  new_rcrd(data[c("pref_code", "pref_name")],
           class = "jpcity_pref")
}

#' Get pref data
#'
#' @param pref A `jpcity_pref` object.
#'
#' @return A data frame.
#'
#' @export
pref_data <- function(pref) {
  data_frame(pref_code = field(pref, "pref_code"),
             pref_name = field(pref, "pref_name"))
}

#' Test if the object is a jpcity_pref object
#'
#' @param x An object.
#'
#' @return `TRUE` if the object inherits from the `jpcity_pref` class.
#'
#' @export
is_pref <- function(x) {
  inherits_any(x, "jpcity_pref")
}

Try the jpcity package in your browser

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

jpcity documentation built on Oct. 4, 2024, 5:11 p.m.