Skip to content
Prev 350853 / 398502 Next

Plotting times at night and getting plot limits correct

Dear Bob,

Is this useful?

library(lubridate)
library(ggplot2)
n <- 100
h <- sample(c(18:23, 0:9), size = n, replace = TRUE)
m <- sample(0:59, size = n, replace = TRUE)
d <- sample(1:3, size = n, replace = TRUE)
dataset <- data.frame(
  Time = as.POSIXct(paste0("2015-01-", d, " ", h, ":", m, ":0")),
  Thing = rnorm(n)
)
dataset$rTime <- round_date(dataset$Time, unit = "day")
dataset$Time2 <- dataset$Time - dataset$rTime + min(dataset$rTime)
ggplot(dataset, aes(x = Time2, y = Thing, colour = factor(rTime))) +
geom_point()

Best regards,


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and
Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey

2015-05-12 16:34 GMT+02:00 Bob O'Hara <rni.boh at gmail.com>: