Not sure how I landed up browsing through Julia for Data Science and Julia Data Science this Saturday evening. Julia is a fascinating language, but I think the learning curve is a bit much for me. Tried making a simple line chart and it’s … pretty hard, although the syntax is quite interesting …
begin
using CSV, DataFrames
using Downloads: download
= "https://storage.dosm.gov.my/cpi/cpi_2d.csv"
URL_DATA download(URL_DATA, "cpi_2d.csv")
= CSV.read("cpi_2d.csv", DataFrame)
df end
begin
using DataFramesMeta
using AlgebraOfGraphics
using CairoMakie
using Dates: Year
@rsubset! df :division == "overall"
end
= @chain df begin
dat @select :date :lagged_index = :index
@rtransform :date = :date + Year(1)
rightjoin(df; on = :date)
@rtransform :yoy = :index / :lagged_index - 1
dropmissing(:yoy)
end
begin
set_aog_theme!()
= data(dat) * mapping(:date, :yoy)
plt = visual(Scatter) + visual(Lines)
layers draw(
* layers,
plt = (
axis = "{:.0%}",
ytickformat = "Year-on-year change, consumer price index, Malaysia",
title = "",
xlabel = "")
ylabel
)end