3 people like it.

Mass shootings in the US

Based on the article "We’re now averaging more than one mass shooting per day in 2015", this calculates when is the best time to go to US to avoid being shot.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
#load "packages/FsLab/FsLab.fsx"
open FSharp.Data
open XPlot.GoogleCharts

type Shooting = HtmlProvider<"http://shootingtracker.com/wiki/Mass_Shootings_in_2015">
let shoots = Shooting.GetSample()

[ for r in shoots.Tables.``Mass Shootings in 2015``.Rows ->
    r.Date.DayOfWeek, r.Killed ]
|> Seq.groupBy fst
|> Seq.sortBy fst
|> Seq.map (fun (d, l) -> d.ToString(), Seq.sumBy snd l)
|> Chart.Column
namespace Microsoft.FSharp
namespace Microsoft.FSharp.Data
type Shooting = obj

Full name: Script.Shooting
val shoots : obj

Full name: Script.shoots
val r : 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 sortBy : projection:('T -> 'Key) -> source:seq<'T> -> seq<'T> (requires comparison)

Full name: Microsoft.FSharp.Collections.Seq.sortBy
val map : mapping:('T -> 'U) -> source:seq<'T> -> seq<'U>

Full name: Microsoft.FSharp.Collections.Seq.map
val d : System.IComparable
val l : seq<System.IComparable * obj>
System.Object.ToString() : string
val sumBy : projection:('T -> 'U) -> source:seq<'T> -> 'U (requires member ( + ) and member get_Zero)

Full name: Microsoft.FSharp.Collections.Seq.sumBy
val snd : tuple:('T1 * 'T2) -> 'T2

Full name: Microsoft.FSharp.Core.Operators.snd
Raw view Test code New version

More information

Link:http://fssnip.net/sc
Posted:9 years ago
Author:Tomas Petricek
Tags: html , type providers , fslab