library(dplyr) library(fosdata)
The fosdata
package contains datasets for the textbook Probability, Statistics, and Data: A Fresh Approach Using R by Darrin Speegle and Bryan Clair.
Install the development version from GitHub with:
# install.packages("remotes") # if needed remotes::install_github("speegled/fosdata")
# 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)"))
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.
To cite package fosdata
in publications, use:
print(citation("fosdata"), style="textVersion")
A BibTeX entry for LaTeX users is:
print(citation("fosdata"), style="bibtex")
for (i in 1:nrow(sets)) { if (!is.na(sets$Source[i])) { cat('####',sets$Item[i],'\n',sets$Source[i],'\n') } }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.