Rows: 168 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (2): country, income_group
dbl (2): democ_score, infect_rate
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
tail(disease_democ)
# A tibble: 6 × 4
country income_group democ_score infect_rate
<chr> <chr> <dbl> <dbl>
1 Turkey Upper middle income 54.8 39
2 Panama Upper middle income 46 40
3 Gabon Upper middle income 34.6 41
4 Venezuela, RB Upper middle income 41.6 42
5 Colombia Upper middle income 44.8 43
6 Brazil Upper middle income 37.2 45
summary(disease_democ)
country income_group democ_score infect_rate
Length :168 Length :168 Min. :15.80 Min. :23.00
N.unique :168 N.unique : 5 1st Qu.:28.40 1st Qu.:27.00
N.blank : 0 N.blank : 0 Median :38.40 Median :32.00
Min.nchar: 4 Min.nchar: 10 Mean :42.78 Mean :33.33
Max.nchar: 24 Max.nchar: 21 3rd Qu.:52.65 3rd Qu.:39.00
Max. :86.60 Max. :48.00
The following object is masked from 'package:dslabs':
gapminder
library(gifski)anim <- p +transition_time(year) +ease_aes("linear")animate(anim, renderer =gifski_renderer())
Warning: Removed 90 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 90 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 91 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 89 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 83 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 83 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 81 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 80 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 80 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 79 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 79 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 79 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 79 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 72 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 71 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 71 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 67 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 66 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 66 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 63 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 63 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 63 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 63 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 62 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 51 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 51 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 47 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 47 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 44 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 44 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 44 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 41 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 41 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 38 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 38 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 35 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 35 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 31 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 29 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 29 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 27 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 27 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 14 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 14 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 13 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 13 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 11 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 10 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 10 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 8 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 8 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 6 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 6 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 6 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 2 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 3 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 4 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 9 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 17 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 17 rows containing missing values or values outside the scale range
(`geom_point()`).
Warning: Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
Removed 185 rows containing missing values or values outside the scale range
(`geom_point()`).
library(tidyverse)library(highcharter)
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Attaching package: 'highcharter'
The following object is masked from 'package:dslabs':
stars
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): iso2c, iso3c, country, region, income
dbl (5): year, gdp_percap, population, birth_rate, neonat_mortal_rate
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
regions <- nations |>group_by(year,region) |>summarize(gdp_tn =sum(gdp_tn, na.rm =TRUE)) |>arrange(year,region)
`summarise()` has regrouped the output.
ℹ Summaries were computed grouped by year and region.
ℹ Output is grouped by year.
ℹ Use `summarise(.groups = "drop_last")` to silence this message.
ℹ Use `summarise(.by = c(year, region))` for per-operation grouping
(`?dplyr::dplyr_by`) instead.
Rows: 47 Columns: 3
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl (3): year, participants, costs
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cols <-c("dodgerblue","orange") # set the color palette to dodger blue and orangehighchart() |>hc_yAxis_multiples(list(title =list(text ="Participants (millions)")),list(title =list(text ="Costs ($ billions)"),opposite =TRUE) ) |>hc_add_series(data = food_stamps$participants,name ="Participants (millions)",type ="column",yAxis =0) |>hc_add_series(data = food_stamps$costs,name ="Costs ($ billions)",type ="line",yAxis =1) |>hc_xAxis(categories = food_stamps$year,tickInterval =5) |>hc_colors(cols) |>hc_chart(style =list(fontFamily ="AvantGarde",fontWeight ="bold"))
Rows: 5275 Columns: 10
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (5): iso2c, iso3c, country, region, income
dbl (5): year, gdp_percap, population, birth_rate, neonat_mortal_rate
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
big4 <- nations |>filter(iso3c %in%c("CHN", "DEU", "JPN", "USA")) |>arrange(year)#Plot 1ggplot(big4, aes(x = year, y = gdp_tn, color = country, group = country)) +labs(title ="China's Rise to Become the Largest Economy",x ="Year",y ="GDP ($ trillion)" ) +geom_line(size =1) +geom_point() +theme_minimal() +scale_color_brewer(palette ="Set1")
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
`summarise()` has regrouped the output.
ℹ Summaries were computed grouped by year and region.
ℹ Output is grouped by year.
ℹ Use `summarise(.groups = "drop_last")` to silence this message.
ℹ Use `summarise(.by = c(year, region))` for per-operation grouping
(`?dplyr::dplyr_by`) instead.
ggplot(regions, aes(x = year, y = gdp_tn, fill = region, group = region)) +labs(title ="GDP by World Bank Region",x ="Year",y ="GDP ($ trillion)" ) +geom_area() +theme_minimal() +scale_fill_brewer(palette ="Set2")