Skip to content

Commit cdaa9a1

Browse files
committed
fixed error with non MEDI y-columns
1 parent 0681d9b commit cdaa9a1

File tree

5 files changed

+75
-63
lines changed

5 files changed

+75
-63
lines changed

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 0.3.8
2-
Date: 2024-07-04 09:38:13 UTC
3-
SHA: 8714a0b64b88a425313e7a6c19913fb3878cf1d0
1+
Version: 0.5.3
2+
Date: 2025-02-24 17:54:45 UTC
3+
SHA: 0681d9bf9f64ece1aa13412aaaef6162f83be5dc

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: LightLogR
22
Title: Process Data from Wearable Light Loggers and Optical Radiation Dosimeters
3-
Version: 0.5.3
3+
Version: 0.5.4
44
Authors@R: c(
55
person("Johannes", "Zauner",
66
email = "johannes.zauner@tum.de", role = c("aut", "cre"),

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# LightLogR 0.5.4
2+
3+
* `gg_photoperiod()` does no longer throw an error when the main plots `y.axis` is not based on a `MEDI` column.
4+
15
# LightLogR 0.5.3
26

37
* small cleanup changes for CRAN submission

R/photoperiod.R

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -380,20 +380,22 @@ solar_noon <- function(coordinates, dates, tz) {
380380
#' [gg_photoperiod()] is a helper function to add photoperiod information to
381381
#' plots generated with [gg_day()] or [gg_days()]. The function can either draw
382382
#' on the `dawn` and `dusk` columns of the dataset or use the `coordinates` and
383-
#' `solarDep` arguments to calculate the photoperiods. For better visibility,
384-
#' the
383+
#' `solarDep` arguments to calculate the photoperiods. The time series must be
384+
#' based on a column called `Datetime`.
385385
#'
386386
#' If used in combination with [gg_doubleplot()], with that function in the
387387
#' `type = "repeat"` setting (either manually set, or because there is only one
388388
#' day of data per group present), photoperiods need to be added separately
389389
#' through [add_photoperiod()], or the second photoperiod in each panel will be
390390
#' off by one day. See the examples for more information.
391-
#'
391+
#'
392392
#' In general, if the photoperiod setup is more complex, it makes sense to add
393393
#' it prior to plotting and make sure the photoperiods are correct.
394394
#'
395395
#' @inheritParams photoperiod
396-
#' @param ggplot_obj A `ggplot` object generated with [gg_day()] or [gg_days()].
396+
#' @param ggplot_obj A `ggplot` object generated with [gg_day()] or [gg_days()]
397+
#' (or [gg_doubleplot()]. The dataset used to create these **must** have a
398+
#' `Datetime` column.
397399
#' @param coordinates A two element numeric vector representing the latitude and
398400
#' longitude of the location. If `NULL`, the default, the function will look
399401
#' for the `dawn` and `dusk` columns in the dataset. If those are not present,
@@ -405,8 +407,8 @@ solar_noon <- function(coordinates, dates, tz) {
405407
#' construct the photoperiod shading. Can be used to change the fill color or
406408
#' other aesthetic properties.
407409
#' @param on.top Logical scalar. If `TRUE`, the photoperiods will be plotted on
408-
#' top of the existing plot. If `FALSE`, the photoperiods will be plotted
409-
#' underneath the existing plot. Default is `FALSE`.
410+
#' top of the existing plot. If `FALSE`, the photoperiods will be plotted
411+
#' underneath the existing plot. Default is `FALSE`.
410412
#'
411413
#' @returns a modified `ggplot` object with the photoperiods added.
412414
#' @export
@@ -415,46 +417,46 @@ solar_noon <- function(coordinates, dates, tz) {
415417
#' @examples
416418
#' coordinates <- c(48.521637, 9.057645)
417419
#' #adding photoperiods to a ggplot
418-
#' sample.data.environment |>
419-
#' gg_days() |>
420+
#' sample.data.environment |>
421+
#' gg_days() |>
420422
#' gg_photoperiod(coordinates)
421-
#'
423+
#'
422424
#' #adding photoperiods prior to plotting
423-
#' sample.data.environment |>
424-
#' add_photoperiod(coordinates, solarDep = 0) |>
425-
#' gg_days() |>
425+
#' sample.data.environment |>
426+
#' add_photoperiod(coordinates, solarDep = 0) |>
427+
#' gg_days() |>
426428
#' gg_photoperiod()
427-
#'
429+
#'
428430
#' #more examples that are not executed for computation time:
429431
#' \donttest{
430432
#' #plotting photoperiods automatically works for both gg_day() and gg_days()
431-
#' sample.data.environment |>
432-
#' gg_day() |>
433+
#' sample.data.environment |>
434+
#' gg_day() |>
433435
#' gg_photoperiod(coordinates)
434-
#'
436+
#'
435437
#' #plotting for gg_doubleplot mostly works fine
436-
#' sample.data.environment |>
437-
#' filter_Date(length = "2 days") |>
438-
#' gg_doubleplot() |>
438+
#' sample.data.environment |>
439+
#' filter_Date(length = "2 days") |>
440+
#' gg_doubleplot() |>
439441
#' gg_photoperiod(coordinates)
440-
#'
441-
#' #however, in cases where only one day of data per group is available, or the
442-
#' #type = "repeat" setting is used, the photoperiods need to be added
442+
#'
443+
#' #however, in cases where only one day of data per group is available, or the
444+
#' #type = "repeat" setting is used, the photoperiods need to be added
443445
#' #separately. Otherwise the second day will be off by one day in each panel.
444-
#' #The visual difference is subtle, and might not be visible at all, as
446+
#' #The visual difference is subtle, and might not be visible at all, as
445447
#' #photoperiod only every changes by few minutes per day.
446-
#'
448+
#'
447449
#' #WRONG
448-
#' sample.data.environment |>
449-
#' filter_Date(length = "1 days") |>
450-
#' gg_doubleplot() |>
450+
#' sample.data.environment |>
451+
#' filter_Date(length = "1 days") |>
452+
#' gg_doubleplot() |>
451453
#' gg_photoperiod(coordinates)
452-
#'
454+
#'
453455
#' #CORRECT
454-
#' sample.data.environment |>
455-
#' filter_Date(length = "1 days") |>
456+
#' sample.data.environment |>
457+
#' filter_Date(length = "1 days") |>
456458
#' add_photoperiod(coordinates) |>
457-
#' gg_doubleplot() |>
459+
#' gg_doubleplot() |>
458460
#' gg_photoperiod()
459461
#' }
460462

@@ -586,7 +588,9 @@ gg_photoperiod <- function(ggplot_obj,
586588
xmin = midnight.before,
587589
xmax = dawn,
588590
ymin = -Inf,
589-
ymax = Inf
591+
ymax = Inf,
592+
y = NULL,
593+
x = NULL
590594
),
591595
alpha = alpha,
592596
...
@@ -597,7 +601,9 @@ gg_photoperiod <- function(ggplot_obj,
597601
xmin = dusk,
598602
xmax = midnight.after,
599603
ymin = -Inf,
600-
ymax = Inf
604+
ymax = Inf,
605+
y = NULL,
606+
x = NULL
601607
),
602608
alpha = alpha,
603609
...

man/gg_photoperiod.Rd

Lines changed: 28 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)