Type Providers

Duration

15 minutes

Lab goals

The primary goal of this lab is to find the two countries in 2010 that had the lowest and highest values for the "Income share held by highest 10%" indicator. During this lab you will connect to the World Bank type provider and write code to extract that specific information.

  1. Create a new library application in your IDE and open the script.fsx file.
  2. Connect to the World Bank type provider via NuGet, then reference and open the data.
  3. Write a query expression to find the highest and lowest values for income in 2010.
  4. Run your code in the REPL
---- Missing Image -----
Tip: Remember to reset your REPL window to clear out any existing values

Steps

Accessing data from the World Bank Type Provider

Our goal is to create an F# script file that lists the countries which, in 2010, had the lowest and highest values for the "Income share held by highest 10%" indicator

  1. Create a new library project and display the REPL window.
  2. Add the FSharp.Data type provider package using NuGet. This will download the appropriate DLL file which we can then reference in our script.
  3. Open the script.fsx file - this is where we will add our code.
  4. Reference and open the FSharp.Data dll file code in your script file. Recall that you will use the r# command to add the reference to the script.

Show Code

  1. Call GetDataContext() to connect to the World Bank Type Provider and assign it to a value.

Show Code

  1. Create a query expression which creates a sequence of countries with indicators of income share by highest 10% in 2010. You will want to generate a Tuple from the query and ignore any countries which do not have the data present (where the value is Double.NaN). See if you can work it out on your own with the intellisense, or use the slides as a guide since the query is very similar.

Show Code

  1. Now you need to filter the sequence by minimum income share and maximum income share
  2. Select your code and use Ctrl+Enter to run it in the REPL. If you need some help, or want to compare your code, the entire solution is provided below.

Show Code

Summary

During this lab you have gained experience connecting to the World Bank type provider and extracting specific data from it.

Go Back