logoalt Hacker News

A little comparison between R and Kap

21 pointsby toshlast Saturday at 4:58 PM3 commentsview on HN

Comments

RodgerTheGreatyesterday at 10:26 PM

In Lil, the readcsv[] function takes an optional string specifying a type for each column to decode:

    purchases:readcsv[read["purchases.csv"] "sii"]
Summing a column:

    sum purchases.amount
To create a summary, we need to reduce each group to a single row:

    select first country sum amount by country from purchases
Discounting:

    select first country sum amount-discount by country from purchases
Lil doesn't have a "median" primitive. Decks can contain multiple modules, but we happen to know this one is alone. Your path will vary:

    stats:first import["stats.deck"]
    select first country sum amount-discount by country where amount<stats.median[amount]*10 from purchases
Calculating the median within each group is merely a matter of reordering clauses:

    select first country sum amount-discount where amount<stats.median[amount]*10 by country from purchases
show 1 reply