Skip to content
Prev 360347 / 398502 Next

clock24.plot/radial plot

Looks like you forgot to load the lubridate package

library(lubridate)

You are calling functions days(), hours(), minutes(), seconds(), and hour() which all come from that package. 

-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352

-----Original Message-----
From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Ogbos Okike
Sent: Friday, April 22, 2016 2:05 PM
To: Ulrik Stervbo
Cc: r-help at r-project.org
Subject: Re: [R] clock24.plot/radial plot

Kind Experts,
Many thanks for your guide. I have tried to figure out something that
can help me plot my own data using the examples you referred me to. I
copied part of the code as:

set.seed(44)
N=500
events <- as.POSIXct("2011-01-01", tz="GMT") +
              days(floor(365*runif(N))) +
              hours(floor(24*rnorm(N))) +  # using rnorm here
              minutes(floor(60*runif(N))) +
              seconds(floor(60*runif(N)))
hour_of_event <- hour(events)
# make a dataframe
eventdata <- data.frame(datetime = events, eventhour = hour_of_event)
# determine if event is in business hours
eventdata$Workday <- eventdata$eventhour %in% seq(9, 17)
library(circular)
eventdata$eventhour <- circular(hour_of_event%%24, # convert to 24 hrs
      units="hours", template="clock24")
rose.diag(eventdata$eventhour, bin = 24, col = "lightblue", main =
"Events by Hour (sqrt scale)",
    prop = 3)
I tried to run the above but got an error message: "Error in
eval(expr, envir, enclos) : could not find function "days"
I was thinking that if I could run this code, I can see what is doing
and then start trying to see if I can adapt it to solve my problem.

Thank you so much for further assistance.
Ogbos
On 4/22/16, Ulrik Stervbo <ulrik.stervbo at gmail.com> wrote:
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.