sample code below comes from package documentation or blog posts by package authors. For more information about a package, you can run help(package="packageName") in R to get info on functions included in the package and, if available, links to package vignettes (R-speak for additional documentation). To see sample code for a particular function, try example(topic="functionName", package="packageName") or simply ?functionName for all available help about a function including any sample code (not all documentation includes samples).
R packages to import public data.
Package Category Description Sample Code More info blscrapeR Economics, Government For specific information about U.S. salaries and employment info, the Bureau of Labor Statistics offers a wealth of data available via this new package. blsAPI package is another option. CRAN. bls_api(c("LEU0254530800", "LEU0254530600"), startyear = 2000, endyear = 2015) Package vignettes quantmod Finance, Government This package is designed for financial modelling but also has functions to easily pull data from Google Finance, Yahoo Finance and the St. Louis Federal Reserve (FRED). CRAN. getSymbols("DEXJPUS",src="https://www.computerworld.com/article/3109890/FRED") Intro on getting data Bureau of Economic Analysis Economics, Government Maintained by Andera Batch at BEA, this taps into the bureau's API to download data sets. CRAN. beaSpecs install_github("ozagordi/weatherData") mydata rnoaa Weather Tap into numerous National Oceanic and Atmospheric Administration APIs, including climate, tornadoes and the Climate Prediction Center. NOAA API key needed. options(noaakey = "yourAPIkey") storms14 rtweet Social Media Tap into Twitter's REST and stream APIs with R. API key needed. CRAN. search_tweets("#rstats", n = 18000, include_rts = FALSE) See the introductory vignette.
Sharon Machlis is Executive Editor, Data & Analytics at IDG, where she works on data analysis and in-house editor tools in addition to writing and editing. Her book Practical R for Mass Communication and Journalism was published in December