2 people like it.
Like the snippet!
worldbank-done.fsx
Comparing university enrollment rate in Czech Republic and OECD countries (works in tryfsharp.org!)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
|
// ---------------------------------------------------------
// Load type provider for World Bank and F# charting library
// ---------------------------------------------------------
open Samples
open Samples.Charting.DojoChart
#r "Samples.WorldBank.dll"
// ---------------------------------------------------------
// Explore university enrollment
// ---------------------------------------------------------
// Create data context connected to WorldBank
let data = WorldBank.GetDataContext()
// Compare some selected countries
let cz = data.Countries.``Czech Republic``.Indicators.``School enrollment, tertiary (% gross)``
let us = data.Countries.``United States``.Indicators.``School enrollment, tertiary (% gross)``
Chart.Combine
[ Chart.Line(cz)
Chart.Line(us) ]
// Compare a list of countries
let countries =
[ data.Countries.France
data.Countries.Greece
data.Countries.``Czech Republic``
data.Countries.``United Kingdom``
data.Countries.``European Union`` ]
Chart.Combine
[ for country in countries ->
let data = country.Indicators.``Central government debt, total (% of GDP)``
Chart.Line(data, Name=country.Name) ]
// ---------------------------------------------------------
// Compare university enrolment with OECD
// ---------------------------------------------------------
// Calculate average data for all OECD members
let oecd =
[ for c in data.Regions.``OECD members``.Countries do
yield! c.Indicators.``School enrollment, tertiary (% gross)`` ]
|> Seq.groupBy fst
|> Seq.map (fun (y, v) -> y, Seq.averageBy snd v)
|> Array.ofSeq
Chart.Combine
[ Chart.Line(oecd)
Chart.Line(us)
Chart.Line(cz) ]
|
val data : obj
Full name: Script.data
val cz : obj
Full name: Script.cz
val us : obj
Full name: Script.us
val countries : obj list
Full name: Script.countries
val oecd : (obj * obj) []
Full name: Script.oecd
val c : obj
module Seq
from Microsoft.FSharp.Collections
val groupBy : projection:('T -> 'Key) -> source:seq<'T> -> seq<'Key * seq<'T>> (requires equality)
Full name: Microsoft.FSharp.Collections.Seq.groupBy
val fst : tuple:('T1 * 'T2) -> 'T1
Full name: Microsoft.FSharp.Core.Operators.fst
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>
Full name: Microsoft.FSharp.Collections.Seq.map
val y : obj
val v : seq<obj * obj>
val averageBy : projection:('T -> 'U) -> source:seq<'T> -> 'U (requires member ( + ) and member DivideByInt and member get_Zero)
Full name: Microsoft.FSharp.Collections.Seq.averageBy
val snd : tuple:('T1 * 'T2) -> 'T2
Full name: Microsoft.FSharp.Core.Operators.snd
module Array
from Microsoft.FSharp.Collections
val ofSeq : source:seq<'T> -> 'T []
Full name: Microsoft.FSharp.Collections.Array.ofSeq
More information