+
+
+Code
+include("utils.jl")
+
+[ Info: loading success
+diff --git a/docs/index.html b/docs/index.html index 3e12cdd..bd17538 100644 --- a/docs/index.html +++ b/docs/index.html @@ -302,6 +302,18 @@ Views of Americans about robot vs. human intelligence, All adults” + +
math4mad
+df=@pipe CSV.File("./data/child-mortality-1960-vs-latest-slope.csv")|>DataFrame|>rename(_,"Observation value - Unit_of_measure: Deaths per 100 live births - Indicator: Under-five mortality rate - Sex: Both sexes - Wealth_quintile: All wealth quintiles"=>:rate)|>select(_,Not(:Code,:Continent,"Population (historical estimates)"))|>dropmissing
Row | +Entity | +Year | +rate | +
---|---|---|---|
+ | String | +Int64 | +Float64 | +
1 | +Afghanistan | +1957 | +37.5905 | +
2 | +Afghanistan | +1958 | +36.9628 | +
3 | +Afghanistan | +1959 | +36.3437 | +
4 | +Afghanistan | +1960 | +35.7301 | +
5 | +Afghanistan | +1961 | +35.1658 | +
6 | +Afghanistan | +1962 | +34.584 | +
7 | +Afghanistan | +1963 | +34.0159 | +
8 | +Afghanistan | +1964 | +33.4848 | +
9 | +Afghanistan | +1965 | +32.9421 | +
10 | +Afghanistan | +1966 | +32.3938 | +
11 | +Afghanistan | +1967 | +31.8366 | +
12 | +Afghanistan | +1968 | +31.2825 | +
13 | +Afghanistan | +1969 | +30.7243 | +
⋮ | +⋮ | +⋮ | +⋮ | +
13461 | +Zimbabwe | +2010 | +8.61062 | +
13462 | +Zimbabwe | +2011 | +8.05877 | +
13463 | +Zimbabwe | +2012 | +7.21463 | +
13464 | +Zimbabwe | +2013 | +6.62226 | +
13465 | +Zimbabwe | +2014 | +6.26086 | +
13466 | +Zimbabwe | +2015 | +6.04718 | +
13467 | +Zimbabwe | +2016 | +5.78704 | +
13468 | +Zimbabwe | +2017 | +5.61751 | +
13469 | +Zimbabwe | +2018 | +5.36877 | +
13470 | +Zimbabwe | +2019 | +5.26659 | +
13471 | +Zimbabwe | +2020 | +5.17696 | +
13472 | +Zimbabwe | +2021 | +4.9522 | +
query_years=[1960,1980,2000,2020]
+ query_countries=["Abkhazia","Uganda","Kenya","Egypt","Spain","Japan","France"]
+ @eval(Main, input_years=query_years)
+ @eval(Main, input_countries =query_countries)
+ @eval(Main,input_points=length(query_years))
+ df=@chain df begin
+ @filter(Year ∈ !!input_years)
+ @group_by(Entity)
+ #filter(d->nrow(d)==4,_)
+ @filter(length(Year)==!!input_points)
+ @arrange(Year)
+ @ungroup
+ coerce(_, :Year=>OrderedFactor)
+ @mutate(rate=round(rate,digits=1))
+ @filter(Entity ∈ !!input_countries)
+ end
Row | +Entity | +Year | +rate | +
---|---|---|---|
+ | String | +Cat… | +Float64 | +
1 | +Egypt | +1960 | +31.8 | +
2 | +Egypt | +1980 | +16.8 | +
3 | +Egypt | +2000 | +4.7 | +
4 | +Egypt | +2020 | +2.0 | +
5 | +France | +1960 | +2.8 | +
6 | +France | +1980 | +1.2 | +
7 | +France | +2000 | +0.5 | +
8 | +France | +2020 | +0.4 | +
9 | +Japan | +1960 | +4.0 | +
10 | +Japan | +1980 | +1.0 | +
11 | +Japan | +2000 | +0.5 | +
12 | +Japan | +2020 | +0.2 | +
13 | +Kenya | +1960 | +19.7 | +
14 | +Kenya | +1980 | +11.1 | +
15 | +Kenya | +2000 | +9.9 | +
16 | +Kenya | +2020 | +3.9 | +
17 | +Spain | +1960 | +5.5 | +
18 | +Spain | +1980 | +1.5 | +
19 | +Spain | +2000 | +0.5 | +
20 | +Spain | +2020 | +0.3 | +
21 | +Uganda | +1960 | +22.3 | +
22 | +Uganda | +1980 | +21.9 | +
23 | +Uganda | +2000 | +14.6 | +
24 | +Uganda | +2020 | +4.4 | +
@rput df
+ R"""
+ # install.packages("CGPfunctions")
+ library(CGPfunctions)
+ newggslopegraph(dataframe = df,
+ Times = Year,
+ Measurement = rate,
+ Grouping = Entity,
+ Title = "Child mortality rate",
+ SubTitle = "1960-2020",
+ Caption = "By R CHARTS",
+ LineThickness = 0.5,
+ # DataLabelPadding =0.2,
+ # DataLabelLineSize = 0.5,
+ # DataLabelFillColor = "lightblue",
+ ThemeChoice = "wsj"
+ )
+ """
RObject{VecSxp}
+math4mad
+Warning: package 'sf' was built under R version 4.2.3
+Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
+Warning: package 'dplyr' was built under R version 4.2.3
+
+Attaching package: 'dplyr'
+The following objects are masked from 'package:stats':
+
+ filter, lag
+The following objects are masked from 'package:base':
+
+ intersect, setdiff, setequal, union
+# install.packages("giscoR")
+library(giscoR)
+
+year_ref <- 2013
+
+nuts2_IT <- gisco_get_nuts(
+ year = year_ref,
+ resolution = 20,
+ nuts_level = 2,
+ country = "Italy") %>%
+ select(NUTS_ID, NAME_LATN)
+
+# Transform the shape
+nuts2_IT_32632 <- st_transform(nuts2_IT, 32632)
+
+# Filter to select data from 2013
+disp_income <- giscoR::tgs00026 %>%
+ filter(time == year_ref) %>%
+ select(-time)
+
+nuts2_IT_32632_data <- nuts2_IT_32632 %>%
+ left_join(disp_income, by = c("NUTS_ID" = "geo"))
+
+plot(nuts2_IT_32632_data[, "values"],
+ breaks = "jenks",
+ main = "Choropleth map")
math4mad
+R"""
+# Seed
+set.seed(1)
+
+# Data
+customers <- sample(50:150, 10)
+potential_customers <- sample(150:500, 10)
+company <- LETTERS[1:10]
+
+# Data frame
+df <- data.frame(company = company,
+ x = customers,
+ y = potential_customers)
+"""
+df=@rget df
+rename!(df,:x=>:customers,:y=>:potential_customers)
+sort(df,:company)
+#df2=@pivot_longer(df, customers:potential_customers)
Row | +company | +customers | +potential_customers | +
---|---|---|---|
+ | String | +Int64 | +Int64 | +
1 | +A | +117 | +234 | +
2 | +B | +88 | +426 | +
3 | +C | +50 | +479 | +
4 | +D | +83 | +412 | +
5 | +E | +136 | +478 | +
6 | +F | +92 | +228 | +
7 | +G | +63 | +362 | +
8 | +H | +131 | +186 | +
9 | +I | +108 | +254 | +
10 | +J | +100 | +366 | +