From the course: Complete Guide to R: Wrangling, Visualizing, and Modeling Data

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Working with XML data

Working with XML data

- [Instructor] We've seen elsewhere how to import hierarchically structured data in XML or JSON format into R. I want to run through a slightly more extended example. I'm just going to be using XML, the same general principle supply for using JSON data. Of course, you'll be using a different package and you may have to specify, but let's see how we can do this in R with an online dataset that comes in XML. So let's start by loading a few packages. The important one on this one is xml2. It's a package for working with XML data. By the way, XML stands for extensible markup language. And it's a very common format for data that's stored on the web. We're going to be using some data that comes from the Missouri data portal, and we're going to get a little bit of financial information. Specifically, we're going to be looking for the salestax rate by county. And to do this, we're first going to save the URL for the dataset that we want. This is the URL for the whole thing. I'm going to save…

Contents