From 58271d9d82004f1e3d326e74789caafe94ad6e94 Mon Sep 17 00:00:00 2001 From: hoehleatsu Date: Sun, 7 May 2017 00:51:40 +0200 Subject: [PATCH] Cosmetics minor cosmetic changes, T/F should always be written as TRUE and FALSE instead --- tasks/chart-sunday-polls-gauss.R | 8 ++++---- tasks/chart-sunday-polls-interpolated.R | 10 +++++----- tasks/chart-sunday-polls.R | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tasks/chart-sunday-polls-gauss.R b/tasks/chart-sunday-polls-gauss.R index 813fd36..ed7def4 100644 --- a/tasks/chart-sunday-polls-gauss.R +++ b/tasks/chart-sunday-polls-gauss.R @@ -1,11 +1,11 @@ -df_rolling_average_and_gauss <- read.csv("data/data-rolling-average-gauss.csv", stringsAsFactors = F, sep=",", encoding ="utf-8") +df_rolling_average_and_gauss <- read.csv("data/data-rolling-average-gauss.csv", stringsAsFactors = FALSE, sep=",", encoding ="utf-8") sunday_data <- df_rolling_average_and_gauss %>% arrange(desc(datum)) %>% filter(datum == datum[1]) %>% select(datum, partei, rolling_average, rolling_upper_ci, rolling_lower_ci) sunday_data sunday_data <- sunday_data[order(sunday_data$rolling_average),] -sunday_data <- mutate(sunday_data, y = as.numeric(order(sunday_data$rolling_average, decreasing = T ))) +sunday_data <- mutate(sunday_data, y = as.numeric(order(sunday_data$rolling_average, decreasing = TRUE ))) do_basic_table_chart <- function(){ sundaychart <- ggplot(data = sunday_data, aes(x = rolling_average, y = -y, xmin = rolling_lower_ci, xmax = rolling_upper_ci , ymax = -y + 0.3, ymin = -y -0.3, color = partei)) + @@ -17,7 +17,7 @@ do_basic_table_chart <- function(){ sztheme_points + scale_y_continuous(breaks = - sunday_data$y, labels = sunday_data$partei) + scale_x_continuous(labels = scales::percent, position = "top") - + article_chart <- sundaychart + geom_label(aes(x = rolling_upper_ci, label = paste0(round(sunday_data$rolling_lower_ci*100, digits = 0), "-", round(sunday_data$rolling_upper_ci*100, digits = 0), "%")), fill = NA, label.size = 0, hjust = - 0.2, family="SZoSansCond-Light", size = 6.35) mobile_chart <- sundaychart + geom_label(aes(x = rolling_upper_ci, @@ -27,4 +27,4 @@ do_basic_table_chart <- function(){ ggsave(file="data/assets/sunday-polls-article.png", plot= article_chart, units = "in", dpi = 144, width = 8.89, height = 3.0) } -do_basic_table_chart() \ No newline at end of file +do_basic_table_chart() diff --git a/tasks/chart-sunday-polls-interpolated.R b/tasks/chart-sunday-polls-interpolated.R index db58318..4ff3324 100644 --- a/tasks/chart-sunday-polls-interpolated.R +++ b/tasks/chart-sunday-polls-interpolated.R @@ -1,6 +1,6 @@ -df_ld <- read.csv("data/data-rolling-average.csv", stringsAsFactors = F, sep = ",", encoding = "utf-8") -df_ci <- read.csv("data/data-ci-values.csv", stringsAsFactors = F, sep=",", encoding ="utf-8") +df_ld <- read.csv("data/data-rolling-average.csv", stringsAsFactors = FALSE, sep = ",", encoding = "utf-8") +df_ci <- read.csv("data/data-ci-values.csv", stringsAsFactors = FALSE, sep=",", encoding ="utf-8") sunday_data <- df_ld %>% arrange(desc(datum)) %>% filter(datum == datum[1]) sunday_data @@ -10,7 +10,7 @@ sunday_data <- cbind(sunday_data, sunday_data_ci) sunday_data <- sunday_data[order(sunday_data$rolling_average),] -sunday_data <- mutate(sunday_data, y = as.numeric(order(sunday_data$rolling_average, decreasing = T ))) +sunday_data <- mutate(sunday_data, y = as.numeric(order(sunday_data$rolling_average, decreasing = TRUE ))) do_basic_table_chart <- function(){ sundaychart <- ggplot(data = sunday_data, aes(x = rolling_average, y = -y, xmin = ci_lower, xmax = ci_higher , ymax = -y + 0.3, ymin = -y -0.3, color = partei)) + @@ -22,7 +22,7 @@ do_basic_table_chart <- function(){ sztheme_points + scale_y_continuous(breaks = - sunday_data$y, labels = sunday_data$partei) + scale_x_continuous(labels = scales::percent, position = "top") - + article_chart <- sundaychart + geom_label(aes(x = ci_higher, label = paste0(round(sunday_data$ci_lower*100, digits = 0), "-", round(sunday_data$ci_higher*100, digits = 0), "%")), fill = NA, label.size = 0, hjust = - 0.2, family="SZoSansCond-Light", size = 6.35) mobile_chart <- sundaychart + geom_label(aes(x = ci_higher, @@ -32,4 +32,4 @@ do_basic_table_chart <- function(){ ggsave(file="data/assets/sunday-polls-article.png", plot= article_chart, units = "in", dpi = 144, width = 8.89, height = 3.0) } -do_basic_table_chart() \ No newline at end of file +do_basic_table_chart() diff --git a/tasks/chart-sunday-polls.R b/tasks/chart-sunday-polls.R index 9c0ff93..c725f04 100644 --- a/tasks/chart-sunday-polls.R +++ b/tasks/chart-sunday-polls.R @@ -1,4 +1,4 @@ -df_rolling_average_and_error <- read.csv("data/data-rolling-average-and-error.csv", stringsAsFactors = F, sep=",", encoding ="utf-8") +df_rolling_average_and_error <- read.csv("data/data-rolling-average-and-error.csv", stringsAsFactors = FALSE, sep=",", encoding ="utf-8") sunday_data <- df_rolling_average_and_error %>% arrange(desc(datum)) %>% filter(datum == datum[1]) %>% select(datum, partei, rolling_average, ci_higher, ci_lower) sunday_data <- unique(sunday_data) @@ -9,7 +9,7 @@ sunday_data$ci_lower <- round(sunday_data$ci_lower, digits = 2) # sunday_data$rolling_average <- round(sunday_data$rolling_average, digits = 2) sunday_data <- sunday_data[order(sunday_data$rolling_average),] -sunday_data <- mutate(sunday_data, y = as.numeric(order(sunday_data$rolling_average, decreasing = T ))) +sunday_data <- mutate(sunday_data, y = as.numeric(order(sunday_data$rolling_average, decreasing = TRUE ))) # sunday_data @@ -22,17 +22,17 @@ do_basic_table_chart <- function(){ sztheme_points + scale_y_continuous(breaks = - sunday_data$y, labels = sunday_data$partei) + scale_x_continuous(labels = scales::percent, position = "top") - + article_chart <- sundaychart + geom_label(aes(x = ci_higher,label = paste0(round(sunday_data$ci_lower*100, digits = 0), "-", round(sunday_data$ci_higher*100, digits = 0), "%")), fill = NA, label.size = 0, hjust = - 0.2, family="SZoSansCond-Light", size = 6.35) - mobile_chart <- sundaychart + + mobile_chart <- sundaychart + geom_label(aes(x = ci_higher,label = paste0(round(sunday_data$ci_lower*100, digits = 0), "-", round(sunday_data$ci_higher*100, digits = 0), "%")), fill = NA, label.size = 0, hjust = - 0.1, family="SZoSansCond-Light", size = 6.35) teaser_chart <- sundaychart + sztheme_teaser + theme(panel.grid.major.y = element_blank()) - + # plot(article_chart) ggsave(file="data/assets/sunday-polls-mobile.png", plot = mobile_chart, units = "in", dpi = 144, width = 4.45, height = 3.0) ggsave(file="data/assets/sunday-polls-article.png", plot= article_chart, units = "in", dpi = 144, width = 8.89, height = 3.0) ggsave(file="data/assets/sunday-polls-teaser.png", plot=teaser_chart, dpi = 72, units = "in", width = 8.89, height = 5.01) } -do_basic_table_chart() \ No newline at end of file +do_basic_table_chart()