CommencerCommencer gratuitement

Exploring unemployment data

Now that you've reviewed the basic steps for handling missing data, you can more easily examine and clean new time series data on the fly.

In this exercise, you'll gain a bit more practice by exploring, cleaning, and plotting data on unemployment, both in the United States in general and in Massachusetts (MA) in particular. An xts object containing this data, unemployment is available in your workspace.

Cet exercice fait partie du cours

Case Study: Analyzing City Time Series Data in R

Afficher le cours

Instructions

  • View summary information about your unemployment data using summary(). Pay close attention to the number of NA's identified in your output. Also note that the min and max values of your time index tell you the period covered by your data.
  • Use na.approx() to remove missing values from your unemployment data through linear interpolation. Save these values back into your unemployment object.
  • Use plot.zoo() to plot your unemployment data. Specify plot.type as "single" to put both US-wide and Massachusetts-specific data on the same plot. Keep the lty argument and the call to legend() as they are.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# View a summary of your unemployment data


# Use na.approx to remove missing values in unemployment data
unemployment <- 

# Plot new unemployment data
plot.zoo(___, plot.type = "___", lty = lty)
legend("topright", lty = lty, legend = labels, bg = "white")
Modifier et exécuter le code