knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

timetrackr

The goal of timetrackr is to visualise simple time-tracking data.

Installation

You can install the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("andrewjpfeiffer/timetrackr")

Example

The timetrackr package assumes you have time-tracking data in CSV format, with no column names, and the following columns in the specified order:

  1. Start datetime, in the format %Y-%m-%d %H:%M %z
  2. Activity, to categorise time-tracking events
  3. Notes, to provide additional detail.

The package also assumes that the data are sorted by start datetime in ascending order. This is the natural ordering if you are using an iOS app like Shortcuts to track time by repeatedly appending to the CSV.

To read data, use the function time_1read(). This function also:

library(timetrackr)
library(magrittr)

example_csv <- paste(
  c(paste(c("2019-10-11 18:00 +1030", "01. Sleep", "I'm asleep"), collapse = ","),
    paste(c("2019-10-12 06:00 +1030", "02. Eat",   "I'm awake"),  collapse = ","),
    paste(c("2019-10-12 22:00 +1030", "03. Party", "I'm tired"),  collapse = ","),
    paste(c("2019-10-13 03:00 +1030", "01. Sleep", "Zzzzzzzzz"),  collapse = ","),
    paste(c("2019-10-13 10:00 +1030", "02. Eat",   "Nomnomnom"),  collapse = ",")),
  collapse = "\n"
)

example_data <- time_1read(example_csv)

example_data

To graph this data, use the functions time_2transform() and time_3plot() in succession.

example_data_transform <- time_2transform(example_data) 

time_3plot(example_data_transform, date_start = "2019-10-12", date_end = "2019-10-12")

If the start and/or end date are omitted from time_3plot(), the minimum and/or maximum date are used respectively:

time_3plot(example_data_transform, date_end = "2019-10-12")
time_3plot(example_data_transform, date_start = "2019-10-12")

By default, the activities will appear in the legend in alphabetical order, and the fill colours are the default colours used by ggplot2: see this StackOverflow answer for more detail.

This behaviour can be customised by using the df_palette_in argument in time_3plot():

my_palette <- tibble::tibble(activity = c("02. Eat", "03. Party", "01. Sleep"),
                             fill = c("blue", "green", "black"))

time_3plot(example_data_transform, df_palette_in = my_palette)

Note well:

Shiny Application

The shiny application for this package can be found at https://andrewjpfeiffer.shinyapps.io/timeplot. To use the application:



andrewjpfeiffer/timetrackr documentation built on Feb. 21, 2020, 4:22 a.m.