How to use data within a function in an R package?

I figured it out, just in case anyone comes across this in the future. How I accomplished this was just loading the data from the /data file in the local environment within the function:

x_check <- function(data) {

  # get reference data
  data("ref", envir=environment())

  # get valid values
  valid_values <- ref %>%
    select(z) %>% 
    unname() %>% 
    unlist() %>% 
    as.character()

  # compare against valid values
  return(
    data %>% 
    mutate(x_valid=ifelse(x %in% valid_values, TRUE, FALSE))
  )
}

See Hadley Wickham's book on R writing packages where he explains how to store data in a package.

"The most common location for package data is (surprise!) data/. Each file in this directory should be a .RData file created by save() containing a single object (with the same name as the file)."

This will make your dataset accessible to any user of your package with packagename::data.