Skip to content

Commit

Permalink
Handle missing values in time_axis
Browse files Browse the repository at this point in the history
  • Loading branch information
kbroman committed May 9, 2024
1 parent 59551aa commit e3db016
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: broman
Version: 0.83-2
Date: 2024-05-08
Version: 0.83-3
Date: 2024-05-09
Title: Karl Broman's R Code
Description: Miscellaneous R functions, including functions related to
graphics (mostly for base graphics), permutation tests, running
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Revision history for the R/broman package
-----------------------------------------

## Version 0.83-2, 2024-05-08
## Version 0.83-3, 2024-05-09

- Allow `NA`s in `runningmean()` and `runningratio()`.

Expand Down
5 changes: 3 additions & 2 deletions R/time_axis.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ time_axis <-
labels=format(prettyx, format)))
}

r <- range(as.numeric(times))
dr <- diff(r)
# determine range
if(!is.null(scale)) {
scales <- c("sec", "min", "hr", "day")
Expand All @@ -71,6 +69,9 @@ time_axis <-
}
}
if(is.null(scale)) {
r <- range(as.numeric(times), na.rm=TRUE)
dr <- diff(r)

if(dr < 70) scale <- "sec"
else if(dr < 60*70) scale <- "min"
else if(dr < 60*60*55) scale <- "hr"
Expand Down

0 comments on commit e3db016

Please sign in to comment.