[R] clock24.plot/radial plot

Ogbos Okike giftedlife2014 at gmail.com
Fri Apr 22 21:34:52 CEST 2016


Dear All,
One hand. Many thanks!! The code run as soon as I loaded lubridate.

Please can you guide me on how to relate this code to my actual data.
My actual data is looking like:
2005/01/01 00:00   4009
2005/01/01 01:00   3969
2005/01/01 02:00   3946
2005/01/01 03:00   3975
2005/01/01 04:00   3960
2005/01/01 05:00   3974
2005/01/01 06:00   3971
2005/01/01 07:00   3970
2005/01/01 08:00   3962
2005/01/01 09:00   3992
2005/01/01 10:00   3955
2005/01/01 11:00   3963
2005/01/01 12:00   3965
2005/01/01 13:00   3947
2005/01/01 14:00   3959
2005/01/01 15:00   3978
2005/01/01 16:00   3967
and it runs for many years.

Many thanks for time.
Ogbos

On 4/22/16, David L Carlson <dcarlson at tamu.edu> wrote:
> 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:
>> I use ggplot2 for all my plotting needs where you can make plots circular
>> with the coord_polar. Maybe this will help you along:
>> http://rstudio-pubs-static.s3.amazonaws.com/3369_998f8b2d788e4a0384ae565c4280aa47.html
>>
>> On Fri, 22 Apr 2016 at 08:31 Ogbos Okike <giftedlife2014 at gmail.com>
>> wrote:
>>
>>> Dear All,
>>> I am trying to generate a circular/radial plot. The script below has a
>>> result I am looking for:
>>> testlen<-rnorm(24)*2+5
>>>  testpos<-0:23+rnorm(24)/4
>>>  clock24.plot(testlen,testpos,main="Test Clock24
>>> (lines)",show.grid=FALSE,
>>>   line.col="green",lwd=3)
>>>  if(dev.interactive()) par(ask=TRUE)
>>>  # now do a 'daylight' plot
>>>  oldpar<-clock24.plot(testlen[7:19],testpos[7:19],
>>>   main="Test Clock24 daytime (symbols)",
>>>   point.col="blue",rp.type="s",lwd=3)
>>>  # reset everything
>>>  par(oldpar)
>>>
>>> I tried to play with the script to work with my data. I read my data:
>>> swe<-scan("onedaydata",list(dates="",time="",count=""))
>>> dates<-swe$dates
>>> times<-swe$time
>>> count<-swe$count.
>>> I tried to replace testlen<-rnorm(24)*2+5 with testlen<-count and
>>> oldpar<-clock24.plot(testlen[7:19],testpos[7:19], with
>>> oldpar<-clock24.plot(testlen[0:23],testpos[0:23], but nothing worked.
>>> The format of my data is 2005/01/01 00:00   4009
>>> 2005/01/01 01:00   3969
>>> 2005/01/01 02:00   3946
>>> 2005/01/01 03:00   3975
>>> 2005/01/01 04:00   3960
>>> 2005/01/01 05:00   3974
>>> 2005/01/01 06:00   3971
>>> 2005/01/01 07:00   3970
>>> 2005/01/01 08:00   3962
>>> 2005/01/01 09:00   3992
>>> 2005/01/01 10:00   3955
>>> 2005/01/01 11:00   3963
>>> 2005/01/01 12:00   3965
>>> 2005/01/01 13:00   3947
>>> 2005/01/01 14:00   3959
>>> 2005/01/01 15:00   3978
>>> 2005/01/01 16:00   3967
>>> 2005/01/01 17:00   3978
>>> 2005/01/01 18:00   3988
>>> 2005/01/01 19:00   4043
>>> 2005/01/01 20:00   4026
>>> 2005/01/01 21:00   3996
>>> 2005/01/01 22:00   3967
>>> 2005/01/01 23:00   3969
>>> 2005/01/02 00:00   3976
>>> 2005/01/02 01:00   3969
>>> 2005/01/02 02:00   3955
>>> 2005/01/02 03:00   3984
>>> 2005/01/02 04:00   3971
>>> 2005/01/02 05:00   3960
>>> 2005/01/02 06:00   3951
>>> 2005/01/02 07:00   3948
>>> 2005/01/02 08:00   3954
>>> 2005/01/02 09:00   3948
>>> 2005/01/02 10:00   3960
>>> 2005/01/02 11:00   3964
>>> 2005/01/02 12:00   3962
>>> 2005/01/02 13:00   3959
>>> 2005/01/02 14:00   3950
>>> 2005/01/02 15:00   3972
>>> 2005/01/02 16:00   3984
>>> 2005/01/02 17:00   3983
>>> 2005/01/02 18:00   3982
>>> 2005/01/02 19:00   3987
>>> 2005/01/02 20:00   3989
>>> 2005/01/02 21:00   3975
>>> 2005/01/02 22:00   3956
>>> 2005/01/02 23:00   3975
>>> 2005/01/03 00:00   3946
>>> 2005/01/03 01:00   3944
>>> 2005/01/03 02:00   3915
>>> 2005/01/03 03:00   3901
>>> 2005/01/03 04:00   3893
>>> 2005/01/03 05:00   3854
>>> 2005/01/03 06:00   3824
>>> 2005/01/03 07:00   3790
>>> 2005/01/03 08:00   3770
>>> 2005/01/03 09:00   3794
>>> 2005/01/03 10:00   3778
>>> 2005/01/03 11:00   3803
>>> 2005/01/03 12:00   3801
>>> 2005/01/03 13:00   3800
>>> 2005/01/03 14:00   3783
>>> 2005/01/03 15:00   3789
>>> 2005/01/03 16:00   3804
>>> 2005/01/03 17:00   3781
>>> 2005/01/03 18:00   3785
>>> 2005/01/03 19:00   3772
>>> 2005/01/03 20:00   3777
>>> 2005/01/03 21:00   3766
>>> 2005/01/03 22:00   3775
>>> 2005/01/03 23:00   3779
>>> 2005/01/04 00:00   3798
>>> 2005/01/04 01:00   3806
>>>
>>> A sample of the plot I want is attached. My data is quite large.
>>> Thanks for your time.
>>> Best wishes
>>> Ogbos
>>> ______________________________________________
>>> 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.
>>
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list