Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tomhopper
Created October 30, 2017 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomhopper/16dd2b7966c5f73172fbbf588710158b to your computer and use it in GitHub Desktop.
Save tomhopper/16dd2b7966c5f73172fbbf588710158b to your computer and use it in GitHub Desktop.
Programmatically access data provided by packages in R
## Access data provided by packages
## List all available data sets, plus ancillary information ####
the_data <- data()
## Extract just the packages as a data frame ####
the_data_df <- data.frame(the_data$results, stringsAsFactors = FALSE)
## Extract specific data sets ####
specific_data <- get(the_data_df$Item[1])
specific_data <- get(the_data_df$Item[2])
specific_data <- get(the_data_df$Item[the_data_df$Item == "women"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment