The goal of timetrackr is to visualise simple time-tracking data.
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("andrewjpfeiffer/timetrackr")
The timetrackr package assumes you have time-tracking data in CSV format, with no column names, and the following columns in the specified order:
%Y-%m-%d %H:%M %z
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
#> # A tibble: 4 x 5
#> start_dttm activity notes end_dttm ind_row_order
#> <dttm> <chr> <chr> <dttm> <lgl>
#> 1 2019-10-11 18:00:00 01. Sleep I'm asle… 2019-10-12 06:00:00 TRUE
#> 2 2019-10-12 06:00:00 02. Eat I'm awake 2019-10-12 22:00:00 TRUE
#> 3 2019-10-12 22:00:00 03. Party I'm tired 2019-10-13 03:00:00 TRUE
#> 4 2019-10-13 03:00:00 01. Sleep Zzzzzzzzz 2019-10-13 10:00:00 TRUE
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()
:
activity
and
fill
.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:
grDevices::col2rgb()
. For example, you may like to use:"#AABBCC"
.grDevices::colors()
, and see
http://bc.bojanorama.pl/wp-content/uploads/2013/04/rcolorsheet.pdf
for an illustration of these colours).The shiny application for this package can be found at https://andrewjpfeiffer.shinyapps.io/timeplot. To use the application:
time_3plot()
) using the date pickers.time_3plot()
will automatically read this
CSV file with the appropriate column names).Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.