library(dplyr)
library(fosdata)

fosdata

The fosdata package contains datasets for the textbook Probability, Statistics, and Data: A Fresh Approach Using R by Darrin Speegle and Bryan Clair.

Installation

Install the development version from GitHub with:

# install.packages("remotes")  # if needed
remotes::install_github("speegled/fosdata")

Package Contents

# Build a data frame "sets" will all the information about each data set
library(fosdata)
sets <- vcdExtra::datasets("fosdata")

# Function to parse the help page and get the source reference
get_source <- Vectorize(function(dset) {
  tryCatch({
    thefile <- help(dset, package="fosdata")
    Rd <- utils:::.getHelpFile(thefile)

    # adapted from https://stackoverflow.com/questions/8918753/r-help-page-as-object
    names(Rd) <- substring(sapply(Rd, attr, "Rd_tag"),2)
    temp_args <- Rd$arguments

    Rd$arguments <- NULL
    myrd <- lapply(Rd, unlist)
    myrd <- lapply(myrd, paste, collapse="")

    temp_args <- temp_args[sapply(temp_args , attr, "Rd_tag") == "\\item"]
    temp_args <- lapply(temp_args, lapply, paste, collapse="")
    temp_args <- lapply(temp_args, "names<-", c("arg", "description"))
    myrd$arguments <- temp_args

    myrd$source
  },
  error = function(x) { NA })
})

# Add source information
sets <- sets %>%
  mutate(Source = get_source(Item))
sets %>% select(Item, Title, dim) %>%
  knitr::kable(col.names = c("Name","Description","Dim (RxC)"))

License

Most of the data sets in this package have a creative commons license. Providing the data in this convenient package is not meant to cancel or to modify the existing licenses in any way. Please refer to the references in the man pages for information on any individual data set.

Citation

To cite package fosdata in publications, use:

print(citation("fosdata"), style="textVersion")

A BibTeX entry for LaTeX users is:

print(citation("fosdata"), style="bibtex")

References

for (i in 1:nrow(sets)) {
  if (!is.na(sets$Source[i])) {
    cat('####',sets$Item[i],'\n',sets$Source[i],'\n')
  }
}


speegled/fosdata documentation built on Feb. 8, 2025, 8:17 a.m.