|
| 1 | +^{:kindly/hide-code true |
| 2 | + :clay {:title "# Noway Clojure Meetup Dec. 2025: Data analysis" |
| 3 | + :quarto {:author [:com.github/teodorlu :daslu] |
| 4 | + :description "Meetup notes" |
| 5 | + :category :clojure |
| 6 | + :type :post |
| 7 | + :date "2025-12-03" |
| 8 | + :tags [:dsp :math :gapminder] |
| 9 | + :draft true}}} |
| 10 | +(ns clojure-norway.meetup-2025-12 |
| 11 | + (:require [scicloj.kindly.v4.api :as kindly] |
| 12 | + [scicloj.kindly.v4.kind :as kind] |
| 13 | + [scicloj.metamorph.ml.rdatasets :as rdatasets] |
| 14 | + [scicloj.tableplot.v1.plotly :as plotly] |
| 15 | + [tablecloth.api :as tc])) |
| 16 | + |
| 17 | +;; - Has GDP per capita improved since 1950? |
| 18 | +;; - Are trends different per continent? |
| 19 | + |
| 20 | +(def ds |
| 21 | + (-> (rdatasets/gapminder-gapminder) |
| 22 | + (tc/order-by :year))) |
| 23 | + |
| 24 | +(-> ds |
| 25 | + (tc/order-by :year) |
| 26 | + (plotly/layer-line {:=x :year |
| 27 | + :=y :gdp-percap |
| 28 | + :=color :country})) |
| 29 | + |
| 30 | +(def kuwait? (comp #{"Kuwait"} :country)) |
| 31 | + |
| 32 | +(def ds-kuwait |
| 33 | + (-> ds |
| 34 | + (tc/order-by [:country :year]) |
| 35 | + (tc/select-rows kuwait?))) |
| 36 | + |
| 37 | +;; Why does gdp per capita decrease in Kuwait? |
| 38 | + |
| 39 | +(-> ds-kuwait |
| 40 | + (plotly/layer-line {:=x :year |
| 41 | + :=y :gdp-percap}) |
| 42 | + (plotly/layer-line {:=x :year |
| 43 | + :=y :pop})) |
| 44 | + |
| 45 | +;; Population has increased sharply. |
| 46 | + |
| 47 | +;; What about total gdp? |
| 48 | + |
| 49 | +(-> ds-kuwait |
| 50 | + (tc/* :gdp [:gdp-percap :pop]) |
| 51 | + (plotly/layer-line {:=x :year |
| 52 | + :=y :gdp})) |
| 53 | + |
| 54 | +;; GDP has been rising, overall, even if GDP per capita has been falling. |
| 55 | + |
| 56 | +(tc/head ds) |
| 57 | + |
| 58 | +(defn select-continent [table continent] |
| 59 | + (-> table |
| 60 | + (tc/select-rows (comp #{continent} :continent)))) |
| 61 | + |
| 62 | +(defn view-continent [continent] |
| 63 | + [continent |
| 64 | + (-> ds |
| 65 | + (select-continent continent) |
| 66 | + (plotly/layer-line {:=x :year |
| 67 | + :=y :gdp-percap |
| 68 | + :=color :country}))]) |
| 69 | + |
| 70 | +(def continents |
| 71 | + (into (sorted-set) |
| 72 | + (tc/column ds :continent))) |
| 73 | + |
| 74 | +continents |
| 75 | + |
| 76 | +(mapv view-continent continents) |
0 commit comments