From c93993781d7edad5edc086c8a55c57cc03ee14c2 Mon Sep 17 00:00:00 2001 From: Jzauner Date: Wed, 29 Nov 2023 10:16:03 +0100 Subject: [PATCH 1/3] fixed the bin2d behaviour and added documentation --- R/gg_day.r | 13 +++++++++++-- man/gg_day.Rd | 10 +++++++++- man/import_Dataset.Rd | 4 ++-- vignettes/articles/Day.Rmd | 12 +++++++----- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/R/gg_day.r b/R/gg_day.r index e72c136..3ad09fc 100644 --- a/R/gg_day.r +++ b/R/gg_day.r @@ -17,6 +17,15 @@ #' [symlog_trans()] for details on tweaking this scale. The scale can also be #' changed to a normal or logarithmic scale - see the y.scale argument for more. #' +#' The default scaling of the color and fill scales is discrete, with the +#' [ggsci::scale_color_jco()] and [ggsci::scale_fill_jco()] scales. To use a +#' continuous scale, use the `jco_color = FALSE` setting. Both `fill` and +#' `color` aesthetics are set to `NULL` by default. For most geoms, this is not +#' important, but geoms that automatically use those aesthetics (like +#' geom_bin2d, where fill = stat(count)) are affected by this. Manually adding +#' the required aesthetic (like `aes_fill = ggplot2::stat(count)` will fix +#' this). +#' #' @param dataset A light logger dataset. Expects a `dataframe`. If not imported #' by [LightLogR], take care to choose a sensible variable for the `x.axis.`. #' @param x.axis,y.axis column name that contains the datetime (x, defaults to @@ -82,7 +91,6 @@ #' sample.data.environment, #' scales = "fixed", #' end.date = "2023-08-16", -#' x.axis = Datetime, #' y.axis.label = "mEDI (lx)", #' aes_col = Id) #' plot @@ -210,10 +218,11 @@ gg_day <- function(dataset, ggplot2::ggplot(ggplot2::aes(x=Time.data, y = !!y)) + eval(geom_function_expr)( ggplot2::aes( + x=Time.data, y = !!y, group = {{ group }}, col = {{ aes_col }}, fill = {{ aes_fill }}, - ), ...) + + ), ...) + ribbon + # Scales -------------------------------------------------------------- jco_color_scheme+ diff --git a/man/gg_day.Rd b/man/gg_day.Rd index 683d457..0cdb449 100644 --- a/man/gg_day.Rd +++ b/man/gg_day.Rd @@ -130,6 +130,15 @@ enables values of 0 in the plot, which are common in light logger data, and even enables negative values, which might be sensible for non-light data. See \code{\link[=symlog_trans]{symlog_trans()}} for details on tweaking this scale. The scale can also be changed to a normal or logarithmic scale - see the y.scale argument for more. + +The default scaling of the color and fill scales is discrete, with the +\code{\link[ggsci:scale_jco]{ggsci::scale_color_jco()}} and \code{\link[ggsci:scale_jco]{ggsci::scale_fill_jco()}} scales. To use a +continuous scale, use the \code{jco_color = FALSE} setting. Both \code{fill} and +\code{color} aesthetics are set to \code{NULL} by default. For most geoms, this is not +important, but geoms that automatically use those aesthetics (like +geom_bin2d, where fill = stat(count)) are affected by this. Manually adding +the required aesthetic (like \code{aes_fill = ggplot2::stat(count)} will fix +this). } \examples{ #use `col`for separation of different sets @@ -137,7 +146,6 @@ plot <- gg_day( sample.data.environment, scales = "fixed", end.date = "2023-08-16", -x.axis = Datetime, y.axis.label = "mEDI (lx)", aes_col = Id) plot diff --git a/man/import_Dataset.Rd b/man/import_Dataset.Rd index ecffdf6..0fec504 100644 --- a/man/import_Dataset.Rd +++ b/man/import_Dataset.Rd @@ -145,7 +145,7 @@ dplyr::slice(1500:1505) \%>\% flextable::flextable() \%>\% flextable::autofit() }\if{html}{\out{}}\if{html}{\out{ -
}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}Datetime\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}TEMPERATURE\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}LIGHT\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}MEDI\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}Id\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:57:44\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}211.74\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}202.08\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:57:54\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}208.03\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}198.66\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:04\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}204.85\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}195.55\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:14\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.81\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}203.59\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}194.36\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:24\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}203.44\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}194.42\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:34\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.81\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}204.31\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}195.30\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{
}} +}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}Datetime\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}TEMPERATURE\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}LIGHT\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}MEDI\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}Id\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:57:44\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}211.74\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}202.08\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:57:54\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}208.03\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}198.66\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:04\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}204.85\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}195.55\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:14\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.81\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}203.59\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}194.36\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:24\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.88\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}203.44\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}194.42\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}2023-08-28 12:58:34\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}26.81\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}204.31\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}195.30\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{

}}\if{html}{\out{}}205_actlumus_Log_1020_20230904101707532.txt\if{html}{\out{}}\if{html}{\out{

}}\if{html}{\out{
}}\if{html}{\out{}} } } diff --git a/vignettes/articles/Day.Rmd b/vignettes/articles/Day.Rmd index b2458b2..1cea6d5 100644 --- a/vignettes/articles/Day.Rmd +++ b/vignettes/articles/Day.Rmd @@ -281,16 +281,18 @@ dataset.LL.partial %>% To create a boxplot representation, we not only need to specify the geom but also what time interval we want the boxplot to span. Here the `cut_Datetime()` function from **LightLogR** comes to the rescue. It will round the datetimes to the desired interval, which then can be specified as the `group` argument of `gg_day()`. While this can be a nice representation, I donĀ“t think it fits our goal for the overall figure in our specific case. -#### `geom_hexplot` +#### `geom_bin2d` ```{r, fig.retina=2, fig.width=7, fig.height = 4, warning=FALSE} -dataset.LL.partial %>% - gg_day( - size = 0.25, facetting = FALSE, geom = "bin2d", bins = 24) + #base plot +dataset.LL.partial %>% gg_day( + size = 0.25, facetting = FALSE, geom = "bin2d", + jco_color = FALSE, bins = 24, aes_fill = stat(count)) + #base plot solar.reference + brown.reference + scale.correction ``` -The geom family of `hex`, `bin2d`, or `density_2d` is particularly well suited if you have many, possibly overlaying observations. It reduces complexity by cutting the x- and y-axis into bins and counts how many observations fall within this bin. By choosing 24 bins, we see dominant values for every hour of the day. +The geom family of `hex`, `bin2d`, or `density_2d` is particularly well suited if you have many, possibly overlaying observations. It reduces complexity by cutting the x- and y-axis into bins and counts how many observations fall within this bin. By choosing 24 bins, we see dominant values for every hour of the day. The `jco_color = FALSE` argument is necessary to disable the default discrete color scheme of `gg_day()`, because a continuous scale is necessary for counts or densities. Finally, we habe to use the `aes_fill = stat(count)` argument to color the bins according to the number of observations in the bin[^4]. + +[^4]: Normally, using `ggplot2::geom_bin2d()` would automatically use the fill aesthetic for this, but `gg_day()` has certain defaults that are favorable in most cases, but is a bit more work here. ### {.unnumbered} From ae8347046fc4406aea9d56ed6041e3003957d181 Mon Sep 17 00:00:00 2001 From: Jzauner Date: Mon, 4 Dec 2023 16:40:22 +0100 Subject: [PATCH 2/3] updated Citation --- inst/CITATION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/CITATION b/inst/CITATION index e46822b..6f36d01 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -11,6 +11,6 @@ bibentry( pages = "", url = "https://github.com/tscnlab/LightLogR", textVersion = paste( - "Zauner, J.; Spitschan, M. (2023): LightLogR: Working With Wearable Light Logger Data. R Package, Available on https://github.com/tscnlab/LightLogR. Funded by EURAMET, co-funded by the European Union, Grant#22NRM05 MeLiDos" + "Zauner, J.; Spitschan, M. (2023): LightLogR: Working With Wearable Light Logger Data. R Package, Available on https://github.com/tscnlab/LightLogR" ) ) From 5461d8e0d87979a70fe45018d969d5b5c344bf4a Mon Sep 17 00:00:00 2001 From: Jzauner Date: Mon, 4 Dec 2023 20:02:56 +0100 Subject: [PATCH 3/3] Added a new device (SpectraWear) and fixed a Bug in another (DeLux) --- R/import_LL.R | 19 +++++++++++++++++++ data/supported.devices.rda | Bin 141 -> 156 bytes 2 files changed, 19 insertions(+) diff --git a/R/import_LL.R b/R/import_LL.R index ed4374e..7ea2f6f 100644 --- a/R/import_LL.R +++ b/R/import_LL.R @@ -204,6 +204,24 @@ imports <- function(device, } import_arguments <- list( + #SpectraWear + SpectraWear = rlang::expr({ + tmp <-suppressMessages( + readr::read_csv(filename, + n_max = n_max, + id = "file.name", + locale = locale, + name_repair = "universal", + ... + )) + tmp <- tmp %>% + dplyr::rename(MEDI = Mel + ) %>% + dplyr::mutate(Datetime = + lubridate::dmy_hms(paste(Date, Time), tz = tz), + Id = paste(.data$id, .data$ls, sep = ".") + ) + }), #Speccy Speccy = rlang::expr({ tmp <-suppressMessages( @@ -228,6 +246,7 @@ import_arguments <- list( id = "file.name", locale = locale, name_repair = "universal", + col_types = c("fccdddddddddddddddddd"), ... )) tmp <- tmp %>% diff --git a/data/supported.devices.rda b/data/supported.devices.rda index 22d6504bc511de99c099d7c8b9caaa5b9c4a8c2c..d832b7633c3f8fd27787a55f922f451ddb8bbd65 100644 GIT binary patch literal 156 zcmV;N0Av3`T4*^jL0KkKS$H!Ja{vG~e}Mn^Z~y=S5C9|u7~rmA-{1fNAOLj{6F@Wo z8W{rgmb~00bc*s89hEhyXh_ zC{|6p?r5zlV|ZH~$;7r*;20iPPX9?Hdlr$4aOV6&%BDcg7X2fsP|FA_yK`>53%Mek KC`ddRhdF>@X*!z# literal 141 zcmV;80CN9AT4*^jL0KkKS^v?Y^8f%ce}MmRZ~y=S5C9|u7+|hq-{1fNAOLhCn3`#( zfYG1^1U*5DMt}eSBLId&3s8v-(Dm|5R^GjS@=pAyiHSrc69WMw8%sB4#hbC~RGuxp v+%?e@*r)-dNT