These R packages import sports, weather, stock data and more (2024)

Close Ad

computerworld

UNITED STATES

  • United States
  • Australia
  • India
  • Netherlands
  • New Zealand
  • United Kingdom

×

Close

Feature

These R packages import sports, weather, stock data and more (2)

');IDG.GPT.IMUCounter = IDG.GPT.IMUCounter + 1; IDG.GPT.defineGoogleTagSlot(slotName, [300,250], false);var options = {screenSize:'971 1115', scriptTags: []};$('#' + slotName).responsiveAd(options);

By Sharon Machlis

Executive Editor, Data & Analytics, Computerworld |

Related Topics

  • Analytics
  • Business Intelligence
  • R Language

There are lots of good reasons you might want to analyze public data, from detecting salary trends in government data to uncovering insights about a potential investment (or your favorite sports team).

But before you can run analyses and visualize trends, you need to have the data. The packages listed below make it easy to find economic, sports, weather, political and other publicly available data and import it directly into R -- in a format that's ready for you to work your analytics magic.

Packages that are on CRAN can be installed on your system by using the R command install.packages("packageName") -- you only need to run this once. GitHub packages are best installed with the devtools package -- install that once with install.packages("devtools") and then use that to install packages from GitHub using the format devtools::install_github("repositoryName/packageName"). Once installed, you can load a package into your working session once each session using the format library("packageName").

Some of the 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).

For more on best R packages, see Great R Packages for data import, wrangling and visualization.

R packages to import public data

PackageCategoryDescriptionSample CodeMore info
blscrapeREconomics, GovernmentFor 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
quantmodFinance, GovernmentThis 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="FRED")Intro on getting data
Bureau of Economic AnalysisEconomics, GovernmentMaintained by Andera Batch at BEA, this taps into the bureau's API to download data sets. CRAN.beaSpecs <- list('UserID' = beaKey , 'Method' = 'GetData', 'datasetname' = 'NIPA', 'TableName' = 'T20305', 'Frequency' = 'Q', 'Year' = 'X', 'ResultFormat' = 'json');
beaPayload <- beaGet(beaSpecs);
See the GitHub repo, including info about recent project changes
edgarWebRFinance, GovernmentThis package is designed to let you search and download data from the U.S. Securities and Exchange Commission, including corporate and mutual-fund financial filings. CRAN.getSymbols("DEXJPUS",src="FRED")See the package vignette
FredRFinance, GovernmentIf you're interested just in Fed data, FredR can access data from the Federal Reserve Economic Data API, including 240,000 US and international data sets from 77 sources. Free API key needed. GitHub.fred <- FredR(api.key)
fred$series.search("GDP")
gdp <- fred$series.observations(series_id = 'GDPC1')
Project's GitHub page
tidycensusGovernment, GISThis package downloads data from the U.S. 10-year census and American Community Survey in R-ready format. In addition, you can import data and_ geospatial files for easy mapping. Free API key needed. (For Canadian Census data, there's a completely separate cancensus package). CRAN.get_acs(state = "CA", county = "Orange", geography = "tract", variables = "B19013_001", geometry = TRUE)Project documentation page
censusapiGovernmentThis aims to be complete and offer data from all the bureau's APIs, not just the decennial Census and ACS. API key required. GitHub.mydata <- getCensus(name="acs5", vintage=2014,
key=mycensuskey,
vars=c("NAME", "B01001_001E", "B19013_001E"),
region="congressional district:*", regionin="state:36")
See the Computerworld tutorial or package's GitHub repo.
ipumsrGovernmentFor those doing heavy-duty Census analysis with raw IPUMS microdata, this package makes it easy to import that data into R. CRAN.read_ipums_micro()See the package vignettes, including the intro vignette.
eu.us.opendataGovernmentThis joint project of the U.S. and European Union governments aims to make it easy to import and compare US and EU data sets. Free U.S. Bureau of Economic Analysis API key needed. GitHub.getRel('gross domestic product', lucky = T, beaKey = myKey)
getRel('gdp', lucky = T, beaKey = myKey)
See the project's README file for installation and usage instructions.
RSocrataGovernmentPull data from any municipality that uses the Socrata data platform. Created by the City of Chicago data team. CRAN.mydata <- read.socrata(
"https://data.cityofchicago.org/
Transportation/Towed-Vehicles/ygr5-vcbg")
RSocrata GitHub repo
forbesListRMiscA bit of a niche offering, this taps into lists maintained by Forbes including largest private companies, top business schools and top venture capitalists. GitHub.#top venture capitalists 2012-2016
mydata <-
get_years_forbes_list_data(years = 2012:2016,
list_name = "Top VCs")
See the project GitHub page. You may need to manually load the tidyr package for code to work.
pollstRPoliticsThis package pulls political polling data from the Huffington Post Pollster API. CRAN.slug <- "donald-trump-favorable-rating"
polls <- pollster_charts_polls(slug)[["content"]]
See the example vignette
data.worldMultiR package to use data sets from data.world. API key needed. CRAN.See examples in GitHub repo.See the Quick Start vignette
LahmanSportsR interface for the famed Lahman baseball database. CRAN.batavg <- battingStats()See this blog post on using R for baseball research
rnoaaWeatherTap into numerous National Oceanic and Atmospheric Administration APIs, including climate, tornadoes and the Climate Prediction Center. NOAA API key needed.options(noaakey = "yourAPIkey")
storms14 <- storm_data(year = 2014)
See this rOpenSci tutorial.
rtweetSocial MediaTap 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.

Related:

  • Analytics
  • Business Intelligence
  • R Language

Sharon Machlis is Director of Editorial Data & Analytics at Foundry, where she works on data analysis and in-house editor tools in addition to writing. Her book Practical R for Mass Communication and Journalism was published by CRC Press. She was named Digital Analytics Association's 2021 Top (Data) Practitioner, winner of the 2023 Jesse H. Neal journalism award for best instructional content, 2014 Azbee national gold award for investigative reporting, and 2017 Azbee gold for how-to article, among other awards. You can find her on Mastodon at masto.machlis.com/@smach.

Follow

Copyright © 2018 IDG Communications, Inc.

It’s time to break the ChatGPT habit

These R packages import sports, weather, stock data and more (2024)

FAQs

What is included in R packages? ›

R packages are extensions to the R statistical programming language. R packages contain code, data, and documentation in a standardised collection format that can be installed by users of R, typically via a centralised software repository such as CRAN (the Comprehensive R Archive Network).

What is the difference between depends and imports in R packages? ›

The main difference is that a package you list in Imports will just be loaded when you use it, whereas a package you list in Depends will be attached when your package is attached. Unless there is a good reason otherwise, you should always list packages in Imports not Depends .

Do I need to install R packages every time? ›

We only need to install a package once on our computer. However, to use the package, we need to load the library every time we start a new R/RStudio environment. You can think of this as installing a bulb versus turning on the light.

What is the R stats package? ›

R is a freely distributed software package for statistical analysis and graphics, developed and managed by the R Development Core Team.

Why do we need R packages? ›

Write an R package to keep track of the miscellaneous R functions that you write and reuse. If they're in a package, it'll be easier to keep track of them, and so you'll be much more likely to reuse them. Write an R package to distribute the data and software that accompany a paper.

How do I import an R package? ›

In R, you can easily install and load additional packages provided by other users. or click Tools > Install packages. Write the package name in the dialog, then click install.

What is importing data in R? ›

Importing data in R programming means that we can read data from external files, write data to external files, and can access those files from outside the R environment.

What are the packages in the R library? ›

Packages in R Programming language are a set of R functions, compiled code, and sample data. These are stored under a directory called “library” within the R environment. By default, R installs a group of packages during installation. Once we start the R console, only the default packages are available by default.

What are the basics of R packages? ›

Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages. Others are available for download and installation.

What packages do I have installed in R? ›

To see what packages are installed, use the installed. packages() command. This will return a matrix with a row for each package that has been installed.

How many packages are there in R? ›

R is the language of data science which includes a vast repository of packages. These packages appeal to different regions which use R for their data purposes. CRAN has 10,000 packages, making it an ocean of superlative statistical work.

Top Articles
Physical activity - staying motivated
Here's How to Do a Roth Conversion That Minimizes Taxes
Somboun Asian Market
Cold Air Intake - High-flow, Roto-mold Tube - TOYOTA TACOMA V6-4.0
Ffxiv Shelfeye Reaver
Craftsman M230 Lawn Mower Oil Change
Wisconsin Women's Volleyball Team Leaked Pictures
Cad Calls Meriden Ct
Wmu Course Offerings
Top Financial Advisors in the U.S.
Corpse Bride Soap2Day
Optum Medicare Support
Pbr Wisconsin Baseball
Espn Expert Picks Week 2
454 Cu In Liters
4156303136
Painting Jobs Craigslist
Kamzz Llc
EASYfelt Plafondeiland
At&T Outage Today 2022 Map
Jordan Poyer Wiki
kvoa.com | News 4 Tucson
Cornedbeefapproved
Aes Salt Lake City Showdown
Stockton (California) – Travel guide at Wikivoyage
Primerica Shareholder Account
Kelley Fliehler Wikipedia
Willys Pickup For Sale Craigslist
County Cricket Championship, day one - scores, radio commentary & live text
Otis Offender Michigan
Stolen Touches Neva Altaj Read Online Free
Www Craigslist Com Shreveport Louisiana
How to Watch the X Trilogy Starring Mia Goth in Chronological Order
Seymour Johnson AFB | MilitaryINSTALLATIONS
Junee Warehouse | Imamother
Tds Wifi Outage
Elgin Il Building Department
Hindilinks4U Bollywood Action Movies
Ticket To Paradise Showtimes Near Marshall 6 Theatre
Pokemon Reborn Locations
Craigslist Tulsa Ok Farm And Garden
Cranston Sewer Tax
412Doctors
Timothy Warren Cobb Obituary
Professors Helpers Abbreviation
Dontrell Nelson - 2016 - Football - University of Memphis Athletics
Copd Active Learning Template
Bonecrusher Upgrade Rs3
The 13 best home gym equipment and machines of 2023
Kidcheck Login
Guidance | GreenStar™ 3 2630 Display
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 6219

Rating: 4.6 / 5 (56 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.