Skip to content

Commit

Permalink
add note
Browse files Browse the repository at this point in the history
add note
  • Loading branch information
math4mad committed Dec 19, 2023
1 parent 4ab8b62 commit a24f153
Show file tree
Hide file tree
Showing 15 changed files with 49,149 additions and 0 deletions.
77 changes: 77 additions & 0 deletions docs/search.json

Large diffs are not rendered by default.

2,175 changes: 2,175 additions & 0 deletions docs/vis/annual-death-rate-by-sex-years.html

Large diffs are not rendered by default.

1,350 changes: 1,350 additions & 0 deletions docs/vis/annual-death-rate-in-diff-age.html

Large diffs are not rendered by default.

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 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.
1,450 changes: 1,450 additions & 0 deletions docs/vis/private-investment-on-ai-by-focus.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
915 changes: 915 additions & 0 deletions docs/vis/use-ggplot-map.html

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions vis/annual-death-rate-by-sex-years.qmd
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
```

90 changes: 90 additions & 0 deletions vis/annual-death-rate-in-diff-age.qmd
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))
```









Loading

0 comments on commit a24f153

Please sign in to comment.