-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
99d2941
commit 2cd4a94
Showing
18 changed files
with
1,248 additions
and
240 deletions.
There are no files selected for viewing
330 changes: 217 additions & 113 deletions
330
Presentations-GeorgiaRS/202309/3-descriptive-statistics.Rmd
Large diffs are not rendered by default.
Oops, something went wrong.
709 changes: 582 additions & 127 deletions
709
Presentations-GeorgiaRS/202309/3-descriptive-statistics.html
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,40 @@ | ||
# Data | ||
small_business_2019_all <- read.csv("data/small_business_2019_all.csv") | ||
View(small_business_2019_all) | ||
|
||
# Exercise 1 | ||
#install.packages("modelsummary") | ||
#install.packages("huxtable") | ||
|
||
# Exercise 2 | ||
df_tbilisi_50 <- filter(small_business_2019, | ||
region == "Tbilisi") %>% | ||
arrange(-income) %>% | ||
filter(row_number() <= 50) | ||
|
||
# Exercise 3 | ||
library(modelsummary) | ||
datasummary_skim(small_business_2019_all) | ||
|
||
# Exercise 4 | ||
datasummary( | ||
age + income + vat_liability ~ N + Mean + SD + Min + Max, | ||
small_business_2019_all | ||
) | ||
|
||
# Exercise 5 | ||
library(huxtable) | ||
stats_table <- datasummary_skim(small_business_2019_all, output = "huxtable") | ||
quick_xlsx(stats_table, file = "quick_stats.xlsx") | ||
|
||
# Exercise 6 | ||
stats_table_custom <- stats_table %>% | ||
set_header_rows(1, TRUE) %>% | ||
set_header_cols(1, TRUE) %>% | ||
set_number_format(everywhere, 2:ncol(.), "%9.0f") %>% | ||
set_align(1, everywhere, "center") %>% | ||
theme_basic() | ||
quick_xlsx( | ||
stats_table_custom, | ||
file = "stats-custom.xlsx" | ||
) |
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,125 @@ | ||
# Data | ||
small_business_2019_all <- read.csv("data/small_business_2019_all.csv") | ||
|
||
# Exercise 1a | ||
library(ggplot2) | ||
ggplot(small_business_2019_all) + | ||
aes(x = taxperiod, | ||
y = vat_liability) + | ||
geom_col() + | ||
labs(title = "Total VAT liability of small businesses in 2019 by month") | ||
|
||
# Exercise 1b | ||
ggplot(small_business_2019_all) + | ||
aes(x = taxperiod, | ||
y = vat_liability) + | ||
geom_col() + | ||
labs(title = "Total VAT liability of small businesses in 2019 by month", | ||
# x-axis title | ||
x = "Month", | ||
# y-axis title | ||
y = "Georgian Lari") + | ||
# telling R not to break the x-axis | ||
scale_x_continuous(breaks = 201901:201912) + | ||
# centering plot title | ||
theme(plot.title = element_text(hjust = 0.5)) | ||
|
||
# Exercise 1c | ||
ggsave("vat_liability_small_2019.png", | ||
width = 20, | ||
height = 10, | ||
units = "cm") | ||
|
||
# Exercise 2a | ||
df_group_month <- small_business_2019_all %>% | ||
select(group, taxperiod, vat_liability) %>% | ||
group_by(group, taxperiod) %>% | ||
summarize(total = sum(vat_liability)) | ||
|
||
# Exercise 2b | ||
ggplot(df_group_month) + | ||
aes(x = taxperiod, | ||
y = total) + | ||
geom_line(aes(color = group)) + | ||
labs(title = "Total VAT liability of small businesses in 2019 by experiment group", | ||
x = "Month", | ||
y = "Georgian Lari") + | ||
scale_x_continuous(breaks = 201901:201912) + | ||
theme(plot.title = element_text(hjust = 0.5)) | ||
|
||
# Exercise 2c | ||
ggplot(df_group_month) + | ||
aes(x = taxperiod, | ||
y = total) + | ||
geom_line(aes(color = group)) + | ||
labs(title = "Total VAT liability of small businesses in 2019 by experiment group", | ||
x = "Month", | ||
y = "Georgian Lari") + | ||
scale_x_continuous(breaks = 201901:201912) + | ||
theme(legend.text = element_text(size = 7), | ||
axis.text.x = element_text(size = 6)) | ||
|
||
# Exercise 2d | ||
ggsave("vat_liability_small_2019_by_group.png", | ||
width = 20, | ||
height = 10, | ||
units = "cm") | ||
|
||
# Exercise 3a | ||
df_month <- small_business_2019_all %>% | ||
select(taxperiod, vat_liability) %>% | ||
group_by(taxperiod) %>% | ||
summarize(total = sum(vat_liability)) | ||
|
||
# Exercise 3b | ||
ggplot(df_month) + | ||
aes(x = taxperiod, | ||
y = total) + | ||
geom_col() + | ||
geom_text(aes(label = total), | ||
position = position_dodge(width = 1), | ||
vjust = -0.5, | ||
size = 3) + | ||
labs(title = "Total VAT liability of small businesses in 2019 by month", | ||
x = "Month", | ||
y = "Georgian Lari") + | ||
scale_x_continuous(breaks = 201901:201912) + | ||
theme(plot.title = element_text(hjust = 0.5)) | ||
|
||
# Exercise 3c | ||
ggplot(df_month) + | ||
aes(x = taxperiod, | ||
y = total) + | ||
geom_col() + | ||
geom_text(aes(label = round(total)), | ||
position = position_dodge(width = 1), | ||
vjust = -0.5, | ||
size = 3) + | ||
labs(title = "Total VAT liability of small businesses in 2019 by month", | ||
x = "Month", | ||
y = "Georgian Lari") + | ||
scale_x_continuous(breaks = 201901:201912) + | ||
theme(plot.title = element_text(hjust = 0.5)) | ||
|
||
# Saving | ||
ggsave("vat_liability_small_2019_text.png", | ||
width = 20, | ||
height = 10, | ||
units = "cm") | ||
|
||
# Exercise 4 | ||
ggplot(small_business_2019_all) + | ||
aes(x = age, | ||
y = vat_liability) + | ||
geom_point() + | ||
labs(title = "VAT liability versus age for small businesses in 2019", | ||
x = "Age of firm (years)", | ||
y = "VAT liability") + | ||
theme(plot.title = element_text(hjust = 0.5)) | ||
|
||
# Saving | ||
ggsave("scatter_age_vat.png", | ||
width = 20, | ||
height = 10, | ||
units = "cm") | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+183 KB
Presentations-GeorgiaRS/202309/img/session3/data-work-descriptive-stats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,8 @@ | ||
$(document).ready(function(){ | ||
if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { | ||
$('[data-toggle="tooltip"]').tooltip(); | ||
} | ||
if ($('[data-toggle="popover"]').popover === 'function') { | ||
$('[data-toggle="popover"]').popover(); | ||
} | ||
}); |
Oops, something went wrong.