x <- 10
x * 2
gapminder |>
filter(year == 2007) |>
group_by(continent) |>
summarise(life_exp_avg = mean(lifeExp))
#| warning: false
library(tidyverse)
library(gapminder)
gapminder
gapminder |>
filter(year == 2007) |>
group_by(continent) |>
summarise(life_exp_avg = mean(lifeExp))
gapminder |>
group_by(year, continent) |>
summarise(life_exp_avg = mean(lifeExp))
gapminder |>
group_by(year, continent) |>
summarise(life_exp_avg = mean(lifeExp)) |>
ggplot() +
aes(x = year, y = life_exp_avg, col = continent)+
geom_line()
library(tidyverse)
library(gt)
#remotes::install_github("jthomasmock/gtExtras")
library(gtExtras)
set.seed(37)
bullet_df <- tibble::rownames_to_column(mtcars) %>%
dplyr::select(rowname, cyl:drat, mpg) %>%
dplyr::group_by(cyl) %>%
dplyr::mutate(target_col = mean(mpg),
ref_col = 25) %>%
dplyr::slice_sample(n = 3) %>%
dplyr::ungroup()
bullet_df %>%
gt() %>%
gt_plt_bullet(column = mpg, target = ref_col, width = 45,
palette = c("darkblue", "red"))
car_summary <- mtcars %>%
dplyr::group_by(cyl) %>%
dplyr::summarize(
n = n(),
mean = mean(mpg),
sd = sd(mpg),
# must end up with list of data for each row in the input dataframe
mpg_data = list(mpg),
.groups = "drop"
)
car_summary
car_summary %>%
arrange(desc(cyl)) %>%
gt() %>%
gtExtras::gt_plt_sparkline(mpg_data) %>%
fmt_number(columns = mean:sd, decimals = 1)
## @knitr package usati
library(tidyverse)
library(janitor)
library(gapminder)
## @knitr prepara_tabella
gap_data <- clean_names(gapminder)
View(gap_data)
gap_data |>
filter(country == "Italy") |>
ggplot() +
aes(x = year, y = life_exp) +
geom_line()
lubridate::today()
