generated from math4mad/quarto-course-website-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add note
- Loading branch information
Showing
15 changed files
with
49,149 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
858 changes: 858 additions & 0 deletions
858
docs/vis/annual-death-rate-in-diff-age_files/figure-html/cell-6-output-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1,031 changes: 1,031 additions & 0 deletions
1,031
docs/vis/annual-death-rate-in-diff-age_files/figure-html/cell-6-output-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
1,225 changes: 1,225 additions & 0 deletions
1,225
docs/vis/private-investment-on-ai-by-focus_files/figure-html/cell-7-output-2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
title: "Annual death rates in people of different ages, by sex world" | ||
author: math4mad | ||
code-fold: true | ||
--- | ||
|
||
:::{.callout-note title="ref"} | ||
- ref :[Annual death rates in people of different ages, by sex](https://ourworldindata.org/life-expectancy#all-charts) | ||
::: | ||
|
||
|
||
```{julia} | ||
include("utils.jl") | ||
``` | ||
|
||
``` | ||
"Entity", "Code", "Year", "Central death rate - Type: period - Sex: female - Age: 0", "Central death rate - Type: period - Sex: male - Age: 0", "Central death rate - Type: period - Sex: female - Age: 10", "Central death rate - Type: period - Sex: male - Age: 10", "Central death rate - Type: period - Sex: female - Age: 15", "Central death rate - Type: period - Sex: male - Age: 15", "Central death rate - Type: period - Sex: female - Age: 25", "Central death rate - Type: period - Sex: male - Age: 25", "Central death rate - Type: period - Sex: female - Age: 45", "Central death rate - Type: period - Sex: male - Age: 45", "Central death rate - Type: period - Sex: female - Age: 65", "Central death rate - Type: period - Sex: male - Age: 65", "Central death rate - Type: period - Sex: female - Age: 80", "Central death rate - Type: period - Sex: male - Age: 80"] | ||
``` | ||
## 2. load data->dataframe | ||
```{julia} | ||
df=@pipe CSV.File("./data/annual-death-rates-in-different-age-groups-by-sex.csv")|>DataFrame | ||
``` | ||
|
||
```{julia} | ||
cats=names(df) | ||
rename!(df, "Central death rate - Type: period - Sex: female - Age: 0"=>:female_age0, | ||
"Central death rate - Type: period - Sex: male - Age: 0"=>:male_age0, | ||
"Central death rate - Type: period - Sex: female - Age: 10"=>:female_age10, | ||
"Central death rate - Type: period - Sex: male - Age: 10"=>:male_age10, | ||
"Central death rate - Type: period - Sex: female - Age: 15"=>:female_age15, | ||
"Central death rate - Type: period - Sex: male - Age: 15"=>:male_age15, | ||
"Central death rate - Type: period - Sex: female - Age: 25"=>:female_age25, | ||
"Central death rate - Type: period - Sex: male - Age: 25"=>:male_age25, | ||
"Central death rate - Type: period - Sex: female - Age: 45"=>:female_age45, | ||
"Central death rate - Type: period - Sex: male - Age: 45"=>:male_age45, | ||
"Central death rate - Type: period - Sex: female - Age: 65"=>:female_age65, | ||
"Central death rate - Type: period - Sex: male - Age: 65"=>:male_age65, | ||
"Central death rate - Type: period - Sex: female - Age: 80"=>:female_age80, | ||
"Central death rate - Type: period - Sex: male - Age: 80" =>:male_age80 | ||
) | ||
``` | ||
|
||
```{julia} | ||
female_data=@chain df begin | ||
@filter(Year==2021) | ||
@select(1,3:17) | ||
@select(startswith("female")) | ||
@summarize(female_age0=mean(female_age0),female_age10=mean(female_age10),female_age15=mean(female_age15),female_age25=mean(female_age25), female_age45=mean(female_age45),female_age65=mean(female_age65),female_age80=mean(female_age80)) | ||
end | ||
``` | ||
```{julia} | ||
male_data=@chain df begin | ||
@filter(Year==2021) | ||
@select(1,3:17) | ||
@select(startswith("male")) | ||
@summarize(male_age0=mean(male_age0),male_age10=mean(male_age10),male_age15=mean(male_age15),male_age25=mean(male_age25),male_age45=mean(male_age45),male_age65=mean(male_age65),male_age80=mean(male_age80)) | ||
end | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
title: "Annual death rates in people of different ages" | ||
author: math4mad | ||
code-fold: true | ||
--- | ||
|
||
:::{.callout-note title="ref"} | ||
- ref :[Annual death rates in people of different ages](https://ourworldindata.org/life-expectancy#all-charts) | ||
::: | ||
|
||
|
||
```{julia} | ||
include("utils.jl") | ||
``` | ||
|
||
``` | ||
["Entity", "Code", "Year", "Central death rate - Type: period - Sex: both - Age: 0", "Central death rate - Type: period - Sex: both - Age: 10", "Central death rate - Type: period - Sex: both - Age: 25", "Central death rate - Type: period - Sex: both - Age: 45", "Central death rate - Type: period - Sex: both - Age: 65", "Central death rate - Type: period - Sex: both - Age: 80"] | ||
``` | ||
## 2. load data->dataframe | ||
```{julia} | ||
df=@pipe CSV.File("./data/annual-death-rates-in-different-age-groups.csv")|>DataFrame | ||
cats=names(df) | ||
rename!(df, "Central death rate - Type: period - Sex: both - Age: 0"=>:age0, | ||
"Central death rate - Type: period - Sex: both - Age: 10"=>:age10, | ||
"Central death rate - Type: period - Sex: both - Age: 25"=>:age25, | ||
"Central death rate - Type: period - Sex: both - Age: 45"=>:age45, | ||
"Central death rate - Type: period - Sex: both - Age: 65"=>:age65, | ||
"Central death rate - Type: period - Sex: both - Age: 80"=>:age80 | ||
) | ||
first(df,10) | ||
``` | ||
|
||
```{julia} | ||
make_title("Part 2: Plot") | ||
``` | ||
|
||
```{julia} | ||
france=@chain df begin | ||
@filter(Entity=="France") | ||
@select(3:9) | ||
@pivot_longer(_, 2:7, names_to = age_group, values_to =rate) | ||
#@group_by(age_group) | ||
end | ||
two_country=@chain df begin | ||
@select(1,3:9) | ||
@pivot_longer(_, 3:8, names_to = age_group, values_to =rate) | ||
@filter(Entity ∈ ["France","South Africa"]) | ||
@group_by(Entity) | ||
@arrange(Year) | ||
@ungroup | ||
end | ||
``` | ||
|
||
<!-- ```{julia} | ||
#| echo: false | ||
data_layer1=data(france) | ||
map_layer=mapping(:Year,:rate,layout=:age_group) | ||
visual_layer1 = visual(Lines,linewidth=1,color=:red) | ||
france_pipe=data_layer1*map_layer1*visual_layer1 | ||
data_layer2=data(southafrica) | ||
visual_layer2 = visual(Lines,linewidth=1,color=:green) | ||
southafrica_pipe=data_layer2*map_layer*visual_layer2 | ||
draw(france_pipe+southafrica_pipe,facet = (;linkyaxes = :none)) | ||
``` --> | ||
|
||
|
||
```{julia} | ||
data_layer=data(two_country) | ||
map_layer=mapping(:Year,:rate,layout=:age_group,color=:Entity) | ||
visual_layer = visual(Lines,linewidth=2) | ||
plt=data_layer*map_layer*visual_layer | ||
draw(plt,facet = (;linkyaxes = :none),legend=(position=:bottom, titleposition=:left, framevisible=true, padding=2)) | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Oops, something went wrong.