BMI 與年齡
在本練習中,你要操作年齡與身體質量指數(BMI)的資料,產生一張圖,說明保單持有人隨年齡變化的平均 BMI 走勢。你會比較兩種作法:一種使用 StatsPlots 的 DataFrame 繪圖 recipe,另一種則不使用。此外,你也會使用 chain 將資料處理與視覺化串接起來。
所需套件 DataFrames、StatsPlots、Statistics 與 Chain 都已為你匯入,insurance DataFrame 也已可直接使用。
本練習屬於課程
Julia 資料視覺化入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
grouped = groupby(insurance, :Age)
mean_bmis = combine(grouped, :BMI => mean)
# Scatter plot
scatter(____.____, ____.____,
label=false, smooth=____,
linewidth=3, linecolor=:maroon1)
xlabel!("Age")
ylabel!("Body Mass Index (BMI)")