Skip to content

Commit

Permalink
adds some plots
Browse files Browse the repository at this point in the history
  • Loading branch information
werpuc committed Dec 4, 2018
1 parent 896d406 commit 6bc9a6d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
10 changes: 6 additions & 4 deletions my_work_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ date,time_up,pomodoros
2018-10-02,NA,NA
2018-10-03,8:45,9
2018-10-04,8:45,9
2018-10-05,8:45,11
2018-10-05,8:45,10
2018-10-06,NA,NA
2018-10-07,NA,NA
2018-10-08,8:30,8
Expand All @@ -50,7 +50,7 @@ date,time_up,pomodoros
2018-10-19,10:45,8
2018-10-20,NA,NA
2018-10-21,NA,NA
2018-10-22,7:05,10
2018-10-22,7:00,10
2018-10-23,9:30,8
2018-10-24,9:30,10
2018-10-25,NA,11
Expand Down Expand Up @@ -90,6 +90,8 @@ date,time_up,pomodoros
2018-11-28,9:30,12
2018-11-29,9:30,10
2018-11-30,7:40,0
2018-12-01,10:30,0
2018-12-01,10:30,NA
2018-12-02,9:30,4
2018-12-03,9:15,NA
2018-12-03,9:15,12
2018-12-04,10:45,10

Empty file added sleep_data_eda.R
Empty file.
46 changes: 45 additions & 1 deletion work_data_eda.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
library(skimr)
library(tidyverse)
library(wesanderson)
library(DT)

# work_data check

Expand Down Expand Up @@ -35,6 +36,7 @@ work_data %>%
# breaks=c("min", "mean", "max"),
# labels=c("min", "mean", "max"))

# pomodoros per month
work_data %>%
filter(wday(date)!=1 & wday(date)!=7) %>%
group_by(month = month(date, label = TRUE)) %>%
Expand All @@ -43,5 +45,47 @@ work_data %>%
ggplot(aes(x = month, y = monthly_pomodoroes)) +
geom_col(fill = colores[1]) +
geom_hline(yintercept = 160, linetype="dashed", color = colores[2]) +
scale_fill_manual(values = colores)
geom_text(aes(3, 160, label = '80 hours', vjust = -.5, color = colores[2])) +
scale_fill_manual(values = colores) +
theme(legend.position="none")

# pomodoros per week

avg_pomodoros_weekly <- work_data %>%
group_by(week_no = week(date)) %>%
summarize(weekly_pomodores = sum(pomodoros, na.rm = TRUE)) %>%
summarize(mean(weekly_pomodores)) %>%
.[[1]] %>%
round()

work_data %>%
group_by(week_no = week(date)) %>%
summarize(weekly_pomodoroes = sum(pomodoros, na.rm = TRUE),
avg_weekly_pomodores = round(mean(pomodoros, na.rm = TRUE), 2)) %>%
mutate(hours = weekly_pomodoroes/2) %>%
ggplot(aes(x = week_no, y = weekly_pomodoroes)) +
geom_col(fill = colores[1]) +
geom_hline(yintercept = 40, linetype="dashed", color = colores[2]) +
geom_text(aes(45, 40, label = '20 hours', vjust = -.5, color = colores[2])) +
scale_fill_manual(values = colores) +
geom_hline(yintercept = avg_pomodoros_ever, linetype = "dashed", color = colores[3]) +
geom_text(aes(45, avg_pomodoros_weekly, label = paste0(avg_pomodoros_weekly/2, ' hours'), vjust = -.5)) +
geom_text(aes(45, avg_pomodoros_weekly, label = 'average', vjust = 1.2)) +
theme(legend.position="none") +
labs(x = 'week', y = 'sum of pomodoros', title = 'Sum of pomodoros per week')

# pomodors per day

avg_pomodoros_daily = round(mean(work_data[wday(work_data$date)!=1 & wday(work_data$date)!=7, ]$pomodoros, na.rm = TRUE))

work_data %>%
mutate(is_workday = (wday(date)!=1 & wday(date)!=7)) %>%
ggplot(aes(x = date, y = pomodoros)) +
geom_col(aes(fill = is_workday), show.legend = TRUE, width = 1) +
scale_fill_manual(values = colores) +
geom_hline(yintercept = avg_pomodoros_daily, linetype = 'dashed', color = colores[3]) +
geom_text(aes(as.Date('2018-11-09'), y = avg_pomodoros_daily, label = paste0(avg_pomodoros_daily/2, ' hours'), vjust = -.5)) +
geom_text(aes(as.Date('2018-11-09'), y = avg_pomodoros_daily, label = 'average', vjust = 1.3)) +
labs(x = 'month', y = 'pomodoros', title = 'Pomodoros in time')


0 comments on commit 6bc9a6d

Please sign in to comment.