Re: [R] Chron object in time series plot
On Wed, Oct 27, 2010 at 8:04 AM, Manta wrote: > > Here it is: > > dput(temp_plot) > structure(c(48608, 46686, 55216, 59268, 50967, 55067, 57783, > 60021, 61480, 63853, 58267, 72442, 63926, 49102, 74320, 63433, > 66256, 68483, 67736, 60507, 60888, 78008, 64326, 65665, 57288, ... > 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L)), .Names = > c("sec", > "min", "hour", "mday", "mon", "year", "wday", "yday", "isdst" > ), class = c("POSIXt", "POSIXlt")), class = "zoo") "POSIXlt" is not supported. You could use "POSIXct" but since this series is based on dates you really should be using "Date" class. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Here it is: dput(temp_plot) structure(c(48608, 46686, 55216, 59268, 50967, 55067, 57783, 60021, 61480, 63853, 58267, 72442, 63926, 49102, 74320, 63433, 66256, 68483, 67736, 60507, 60888, 78008, 64326, 65665, 57288, 54663, 54984, 54073, 59632, 52523, 55266, 54836, 61408, 53813, 85855, 65204, 65237, 65386, 72440, 64335, 66812, 71059, 97227, 81343, 72752, 69940, 66824, 68161, 71851, 70554, 65266, 68625, 71335, 81673, 81056, 78679, 134337, 107247, 81789, 76810, 80960, 119172, 75880, 72860, 73103, 71624, 74183, 66257, 66628, 69924, 69067, 78297, 73155, 67726, 81009, 72150, 76210, 66699, 67089, 70831, 70331, 77818, 69351, 100517, 79164, 70265, 66103, 69252, 65142, 68796, 53462, 69156, 67666, 76773, 71388, 86664, 73797, 73574, 65747, 74917, 55861, 82358, 74798, 74612, 104735, 80963, 72207, 69717, 73136, 71510, 81028, 77177, 79918, 78429, 74626, 94630, 70656, 84971, 70483, 125973, 77244, 65397, 66222, 70337, 77021, 131867, 77465, 77222, 74967, 60717, 90881, 66957, 73513, 72002, 68725, 73627, 74682, 69916, 82452, 72760, 78359, 65829, 68001, 69599, 71846, 76152, 69157, 70879, 94113, 73165, 75785, 66459, 64793, 67792, 67008, 71439, 69351, 65798, 67541, 60581, 72968, 68596, 60298, 62683, 62784, 63788, 62189, 62845, 68497, 92736, 56241, 77853, 62631, 67106, 66784, 73911, 71624, 70445, 70645, 68280, 82238, 69494, 84873, 72322, 71644, 141039, 69875, 75809, 75740, 72291, 82001, 112207, 77301, 74891, 66174, 78673, 71568, 74161, 72637, 76319, 63865, 86245, 79936, 70111, 84724, 77605, 65705, 68845, 67050, 68067, 75717, 68569, 70312, 72908, 94667, 80676, 67476, 66741, 65356, 66114, 76292, 47900, 71286, 60364, 67148, 77616, 74471, 63236, 66738, 63149, 70542, 65356, 70004, 51889, 114181, 74867, 68344, 67922, 67944, 67311, 67256, 61800, 63579, 62871, 66727, 82564, 65914, 87377, 71340, 76553, 151547, 77076, 55924, 88334, 81379, 76241, 66267, 66703, 47769, 57789, 58453, 63042, 68832, 65280, 63149, 73836, 68070, 67080, 78539, 65219, 65543, 63284, 68362, 59752, 61295, 62870, 94422, 78799, 65259, 62690, 63387, 63384, 66303, 62744, 58081, 63833, 61526, 55744, 75378, 71157, 61070, 64107, 65150, 60796, 62014, 62518, 102311, 77248, 66569, 64852, 64380, 64174, 67343, 64848, 62277, 62970, 61354, 80303, 61572, 80076, 61844, 114489, 73097, 61743, 63115, 64720, 64513, 78685, 94289, 80291, 67795, 65055, 69651, 62361, 62577, 65192, 94212, 77631, 67765, 75268, 67084, 59755, 61911, 64776, 62846, 73513, 62644, 63456, 96677, 75582, 73025, 63858, 65571, 60514, 68342, 64878, 64818, 64045, 68645, 69275, 72810, 67539, 45887, 62838, 51186, 72647, 65198, 64534, 92919, 52069, 62405, 61744, 62126, 67360, 66420, 62396, 65454, 54787, 61866, 75287, 59147, 78781, 62675, 60042, 119296, 55693, 58992, 62469, 64651, 71012, 105284, 84969, 67569, 62990, 70183, 57815, 59899, 59552, 62056, 63563, 57481, 66382, 57909, 74477, 69128, 56630, 61116, 59082, 59698, 69367, 59843, 64375, 65207, 86610, 77313, 66559, 65058, 62612, 59885, 62675, 58903, 56684, 55544, 56327, 72775, 66894, 53771, 54721, 53036, 59793, 56515, 57209, 58488, 67520, 69302, 69654, 61885, 59460, 59775, 52246, 63949, 57443, 59870, 59297, 67708, 65754, 62581, 75979, 59169, 102333, 57338, 56431, 60008, 62672, 71023, 62911, 99488, 88818, 67845, 70389, 61413, 60323, 59177, 61979, 52560, 68488, 62023, 66312, 63326, 82250, 62942, 61747, 62375, 60358, 67121, 62758, 63918, 64186, 92093, 77806, 64452, 59965, 64093, 60948, 66461, 59339, 45189, 65586, 58171, 73753, 55382, 71458, 59880, 61807, 62968, 59051, 65381, 48991, 69415, 89953, 75686, 64938, 60754, 60494, 69836, 57011, 62142, 60945, 60932, 66224, 69208, 66776, 78374, 66130, 106111, 68456, 69241, 46106, 61252, 59468, 79293, 66035, 84721, 52301, 49248, 54730, 54540, 61200, 57584, 58317, 59153, 68502, 54020, 82374, 60477, 61899, 64261, 70799, 61002, 62723, 62757, 92339, 81700, 66365, 63671, 61148, 61646, 66227, 60950, 59189, 58674, 58191, 48739, 67047, 63350, 52915, 54475, 63922, 55320, 59045, 63258, 90478, 80147, 64763, 60530, 59481, 58768, 61304, 55695, 58767, 57455, 56949, 69357, 62254, 75421, 57546, 56729, 90247, 56569, 57736, 57762, 61892, 70410, 66461, 89713, 87875, 92100, 73486, 62624, 63171, 66036, 63212, 60684, 66067, 60262, 79552, 60582, 59066, 60890, 59358, 71090, 64570, 62780, 63743, 92339, 66058, 65701, 59996, 66059, 68367, 77693, 67652, 69675, 47731, 76049, 71133, 61604, 63582, 65521, 64197, 54465, 66390, 61789, 63350, 74628, 60384, 87954, 62537, 55254, 60611, 64248, 61040, 62114, 62519, 61068, 63435, 68241, 62982, 76833, 58901, 94860, 58294, 54924, 59305, 57068, 65539, 60810, 101727, 87998, 65855, 58772, 69076, 58758, 59727, 57736, 63014, 55337, 54919, 63230, 57756, 80296, 58319, 56993, 59161, 56184, 65331, 56179, 61115, 59874, 85050), index = structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Re: [R] Chron object in time series plot
On Wed, Oct 27, 2010 at 7:33 AM, Manta wrote: > > This is the output, thanks again for the help! > > structure(c(48608, 46686, 55216, 59268, 50967, 55067, 57783, > 60021, 61480, 63853, 58267, 72442, 63926, 49102, 74320, 63433, > ... > 55337, 54919, 63230, 57756, 80296, 58319, 56993, 59161, 56184, It did not come through properly. There are strange dots in the middle of it. It must be sent in a reproducible fashion so that it is possible to copy it from your email and paste it into a running R session. Send it as a text attachment if you can't get it to work in the body of the email. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
This is the output, thanks again for the help! structure(c(48608, 46686, 55216, 59268, 50967, 55067, 57783, 60021, 61480, 63853, 58267, 72442, 63926, 49102, 74320, 63433, ... 55337, 54919, 63230, 57756, 80296, 58319, 56993, 59161, 56184, 65331, 56179, 61115, 59874, 85050), index = structure(list(sec = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, .. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), min = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, .. 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), hour = c(0L, .. 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), mday = c(2L, 3L, 4L, 7L, 8L, 9L, 10L, 11L, 14L, 15L, 16L, 17L, 18L, 21L, 22L, 23L, 24L, 25L, 28L, 29L, 30L, 31L, ... 3L, 4L, 7L, 8L, 9L, 10L, 11L, 14L, 15L, 16L, 17L, 18L, 21L, 22L, 23L, 24L, 25L, 28L, 29L, 30L, 1L, 2L, 5L, 6L, 7L, 8L, 9L, 12L, 13L, 14L, 15L, 16L, 19L, 20L, 21L, 22L, 23L, 26L, 27L, 28L, 29L, 30L), mon = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, --- 4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L, 6L), year = c(108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, 108L, ...- 110L, 110L, 110L, 110L, 110L, 110L, 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, Manta wrote: > > Ok, so you may be right, but I do not understand why ;) > > The commands you suggested are applied to temp_plot, where temp_plot is a > 'zoo' object as follows (there is actually something strange in here, if I > just want to see the whole object I do not get the warning message that I > got when selecting a sample): > > temp_plot[1:10] > 2008-01-02 2008-01-03 2008-01-04 2008-01-07 2008-01-08 2008-01-09 2008-01-10 > 48608 46686 55216 59268 50967 55067 57783 > 2008-01-11 2008-01-14 2008-01-15 > 60021 61480 63853 > Warning message: > In zoo(rval[i], x.index[i]) : > some methods for “zoo” objects do not work if the index entries in > ‘order.by’ are not unique > To unambiguously communicate what you have show the output of dput(temp_plot) . -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Ok, so you may be right, but I do not understand why ;) The commands you suggested are applied to temp_plot, where temp_plot is a 'zoo' object as follows (there is actually something strange in here, if I just want to see the whole object I do not get the warning message that I got when selecting a sample): temp_plot[1:10] 2008-01-02 2008-01-03 2008-01-04 2008-01-07 2008-01-08 2008-01-09 2008-01-10 48608 46686 55216 59268 50967 55067 57783 2008-01-11 2008-01-14 2008-01-15 60021 61480 63853 Warning message: In zoo(rval[i], x.index[i]) : some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique First command: > temp_plot[duplicated(time(temp_plot))] Data: numeric(0) Index: character(0) Warning message: In zoo(rval[i], x.index[i]) : some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique Second command table(time(temp_plot)) , , hour = 0, mday = 23, mon = 7, year = 110, wday = 2, yday = 1, isdst = 0 min sec 0 0 0 , , hour = 0, mday = 24, mon = 7, year = 110, wday = 2, yday = 1, isdst = 0 min sec 0 0 0 , , hour = 0, mday = 25, mon = 7, year = 110, wday = 2, yday = 1, isdst = 0 min sec 0 0 0 Third command: aggregate(temp_plot,identity,length) Error: length(time(x)) == length(by[[1]]) is not TRUE Well, I believe there is something indeed going on here! If I understood correctly, the second command tells me that is not able to recognize in the correct way the year (and most likely all the rest) while the third indicates a mismatch in the dimensions. Marco -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3015182.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Tue, Oct 26, 2010 at 12:56 PM, Manta wrote: > > Thanks for your help Gabor. That would be exactly what I am looking for. If I > use your code I get the nice representation I am looking for. However, when > I try to apply the code in the same fashion to my case, it does not produce > the x-axis. I believe the problem hinges on the following warning message I > got when creating the 'zoo' object: Warning message: In zoo(trans_numb, > xtime): some methods for “zoo” objects do not work if the index entries in > ‘order.by’ are not unique > > Actually, I do not understand why I get this warning, as my series is > irregularly spaced, but does not have any duplicate (i.e. one observation > per business day). Maybe your series is not what you think it is. Try any of these: z[duplicated(time(z))] table(time(z)) aggregate(z, identity, length) to find the duplicates. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Thanks for your help Gabor. That would be exactly what I am looking for. If I use your code I get the nice representation I am looking for. However, when I try to apply the code in the same fashion to my case, it does not produce the x-axis. I believe the problem hinges on the following warning message I got when creating the 'zoo' object: Warning message: In zoo(trans_numb, xtime): some methods for “zoo” objects do not work if the index entries in ‘order.by’ are not unique Actually, I do not understand why I get this warning, as my series is irregularly spaced, but does not have any duplicate (i.e. one observation per business day). -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3014100.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Wonderful! Thanks a lot for your help, super appreciated! -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3012793.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Mon, Oct 25, 2010 at 4:12 PM, Manta wrote: > > I apologize for not being very precise. I meant the tick marks on the x-axis. > > As for the code, the situation is just the one describe above, just that I > would like to be able to specify the tick marks (say every 3 or 6 months). Using z and zjj from before: plot(z, xaxt = "n") axis(1, as.Date(time(zjj)), time(zjj)) or fancier: plot(z, xaxt = "n") jan <- as.numeric(format(time(zjj), "%m")) == 1 tt <- time(zjj) axis(1, as.Date(tt)[jan], format(tt[jan], "%Y")) axis(1, as.Date(tt)[!jan], format(tt, "%b")[!jan], tcl = -0.2) -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
I apologize for not being very precise. I meant the tick marks on the x-axis. As for the code, the situation is just the one describe above, just that I would like to be able to specify the tick marks (say every 3 or 6 months). -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3012733.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Mon, Oct 25, 2010 at 3:48 PM, Manta wrote: > > My bad! What I meant is that I want to plot the whole series, but the legend > in the x-axis would only present some specific months depending on the > window I want to choose, say 6 months. At the moment, it only present 2008, > 2009 and 2010. > What is the "legend on the x-axis"? Do you mean the tick marks on the X axis or are you referring to some sort of legend that has not been described? Please follow the last line to every message to r-help. Please ensure that your code is self contained and its minimal. Don't just give us your code but take the time to reduce the code and the data to something minimal, self-contained and reproducible: "and provide commented, minimal, self-contained, reproducible code" -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
My bad! What I meant is that I want to plot the whole series, but the legend in the x-axis would only present some specific months depending on the window I want to choose, say 6 months. At the moment, it only present 2008, 2009 and 2010. Thanks -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3012712.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Mon, Oct 25, 2010 at 3:01 PM, Manta wrote: > > I would like to thank you all for the help given so far! > > I have the following object of the class 'zoo' > >> temp_mean_plot[31:35] > 2008-02-13 2008-02-14 2008-02-15 2008-02-18 2008-02-19 > 14.86834 14.89609 14.89358 14.87610 14.87652 > > The sample runs from Jan 2008 to July 2010. How can I specify to plot for > example Jan08, Jul08, Jan09 etc? > > I've seen some example as in example(plot.zoo) but I cant get exactly how to > replicate it for my purpose. Any help will be highly appreciated again. Assuming that you are looking for a single plot that shows the last point in each January and the last point in each July and no other point then the following creates a test series, z, and aggregates it down to a monthly series, picks off the January and July months and plots: library(zoo) # test data z <- zooreg(1:1000, start = as.Date("2000-01-01")) zym <- aggregate(z, as.yearmon, function(x) tail(x, 1)) mon <- as.numeric(format(time(zym), "%m")) zjj <- zym[mon %% 6 == 1, ] plot(zjj, type = "o"); grid() -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
I would like to thank you all for the help given so far! I have the following object of the class 'zoo' > temp_mean_plot[31:35] 2008-02-13 2008-02-14 2008-02-15 2008-02-18 2008-02-19 14.86834 14.89609 14.89358 14.87610 14.87652 The sample runs from Jan 2008 to July 2010. How can I specify to plot for example Jan08, Jul08, Jan09 etc? I've seen some example as in example(plot.zoo) but I cant get exactly how to replicate it for my purpose. Any help will be highly appreciated again. Marco -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3012629.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Wed, Oct 20, 2010 at 11:08 AM, Manta wrote: > > Sorry R community, I am still stucked wit this. How can avoid the x-limit > error? If the problem is that you wish to create and plot an hourly series at 12 successive hours starting at 7am then here are three ways depending on whether we wish to use chron's "times" class, its "chron" class or "POSIXct" class. (Do not use "POSIXlt" class for this.) We use 1, 2, 3, ..., 12 for the data of our series for these examples. "chron" measures time in days and there are 24 hours in a day hence freq = 24 in the first two examples. POSIXct measures time in seconds and there are 3600 seconds in an hour so deltat = 3600 in the third example.You can find further discussion in an article in R News 4/1.Also see ?zooreg # using "times" class library(zoo); library(chron) z1 <- zooreg(1:12, times("07:00:00"), freq = 24) plot(z1, type = "o") # using "chron" class library(zoo); library(chron) z2 <- zooreg(1:12, chron("1/1/1970", "07:00:00"), freq = 24) plot(z2, type = "o") # using "POSIXct" class library(zoo) z3 <- zooreg(1:12, as.POSIXct("1970-01-01 07:00:00"), deltat = 3600) plot(z3, type = "o") -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Well, I was listening, but the error was due to the extra function 'format'. Without that, it works perfectly. Thanks for the help, Marco -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3004177.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
It seems David and Phil have given you all the pieces and you are not listening. Try: h = sprintf('%06d', seq(07,18, by=1) ) # Note that h is text myseries=sample(1:12, 12) #fake data to plot tim=strptime(h,'%H%M%S') library(zoo) test=zoo(myseries, tim) plot(test) Rob -- From: "Manta" Sent: Wednesday, October 20, 2010 10:08 AM To: Subject: Re: [R] Chron object in time series plot Sorry R community, I am still stucked wit this. How can avoid the x-limit error? -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3004070.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Sorry R community, I am still stucked wit this. How can avoid the x-limit error? -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3004070.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
Thanks Phil, it is exactly what I was looking for. David, I took into account how to make valid math operations, so I understand your concern about it. I will definitely change all my scripts and functions to considered the time as character, but as I need a clear output soon (deadline is close) I do not have the time now to go through all of them. But thanks again for your useful comment. There is still a remaining issue. If I do the following: test=zoo(myseries,format(strptime(sprintf('%06d',breaks),'%H%M%S'),'%H:%M')) plot(test) it does not work, as it says the following error (sorry for the Italian words) Errore in plot.window(...) : i valori 'xlim' devono essere finiti Inoltre: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : si è prodotto un NA per coercizione 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf Thanks again for your help. -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002553.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Oct 19, 2010, at 1:30 PM, Phil Spector wrote: The following will create a POSIXlt object using the current date: strptime(sprintf('%06d',breaks),'%H%M%S') [1] "2010-10-19 07:00:00" "2010-10-19 07:15:00" "2010-10-19 07:30:00" [4] "2010-10-19 07:45:00" "2010-10-19 08:00:00" "2010-10-19 08:15:00" [7] "2010-10-19 08:30:00" "2010-10-19 08:45:00" "2010-10-19 09:00:00" . . . To get just the hours and minutes, you could use format(strptime(sprintf('%06d',breaks),'%H%M%S'),'%H:%M') [1] "07:00" "07:15" "07:30" "07:45" "08:00" "08:15" "08:30" "08:45" "09:00" [10] "09:15" "09:30" "09:45" "10:00" "10:15" "10:30" "10:45" "11:00" "11:15" . . . And I'm still not sure I've answered your question. - Phil Spector On Tue, 19 Oct 2010, Manta wrote: I do not think that importing the time as character will help me, as I need to perform several operation with them. Notice that Phil needed to recast these as a character vector with sprintf() before passing the result to strptime. You cannot do any (valid) mathematical operations on them such as substraction or addition, since they should have no numerical values between 60*60 and 2*60*60. Furthermore, any plotting of the "numerical" values will create illusory gaps. Any operation you do on them needs to first pass through a stage that recognizes that they do not possess the necessary attributes to be numbers. I think your resistance to making them character values in the first place is entirely misguided. -- David. Again, maybe I am not able to express clearly enough. Let's just focus on this series: breaks [1] 7 71500 73000 74500 8 81500 83000 84500 9 91500 93000 94500 10 101500 103000 104500 [17] 11 111500 113000 114500 12 121500 123000 124500 13 131500 133000 134500 14 141500 143000 144500 [33] 15 151500 153000 154500 16 161500 163000 164500 17 171500 173000 174500 18 181500 183000 184500 I want a simple function that can convert breaks into a treatable object by 'zoo' as follows: [1] 07:00 07:15 07:30 .. [33]... 18:00 18:15 18:30 18:45 Is this possible? -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002458.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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@r-project.org mailing list 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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
The following will create a POSIXlt object using the current date: strptime(sprintf('%06d',breaks),'%H%M%S') [1] "2010-10-19 07:00:00" "2010-10-19 07:15:00" "2010-10-19 07:30:00" [4] "2010-10-19 07:45:00" "2010-10-19 08:00:00" "2010-10-19 08:15:00" [7] "2010-10-19 08:30:00" "2010-10-19 08:45:00" "2010-10-19 09:00:00" . . . To get just the hours and minutes, you could use format(strptime(sprintf('%06d',breaks),'%H%M%S'),'%H:%M') [1] "07:00" "07:15" "07:30" "07:45" "08:00" "08:15" "08:30" "08:45" "09:00" [10] "09:15" "09:30" "09:45" "10:00" "10:15" "10:30" "10:45" "11:00" "11:15" . . . And I'm still not sure I've answered your question. - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Tue, 19 Oct 2010, Manta wrote: I do not think that importing the time as character will help me, as I need to perform several operation with them. Again, maybe I am not able to express clearly enough. Let's just focus on this series: breaks [1] 7 71500 73000 74500 8 81500 83000 84500 9 91500 93000 94500 10 101500 103000 104500 [17] 11 111500 113000 114500 12 121500 123000 124500 13 131500 133000 134500 14 141500 143000 144500 [33] 15 151500 153000 154500 16 161500 163000 164500 17 171500 173000 174500 18 181500 183000 184500 I want a simple function that can convert breaks into a treatable object by 'zoo' as follows: [1] 07:00 07:15 07:30 .. [33]... 18:00 18:15 18:30 18:45 Is this possible? -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002458.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
I do not think that importing the time as character will help me, as I need to perform several operation with them. Again, maybe I am not able to express clearly enough. Let's just focus on this series: > breaks [1] 7 71500 73000 74500 8 81500 83000 84500 9 91500 93000 94500 10 101500 103000 104500 [17] 11 111500 113000 114500 12 121500 123000 124500 13 131500 133000 134500 14 141500 143000 144500 [33] 15 151500 153000 154500 16 161500 163000 164500 17 171500 173000 174500 18 181500 183000 184500 I want a simple function that can convert breaks into a treatable object by 'zoo' as follows: [1] 07:00 07:15 07:30 .. [33]... 18:00 18:15 18:30 18:45 Is this possible? -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002458.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Oct 19, 2010, at 12:19 PM, Manta wrote: David Winsemius wrote: You seen to be under the mistaken impression that the internal representation of DateTime classes of 08:00 would be 8. Since the internal representation of time is in seconds, the even number hours would be at integer multiples of 60*60. In addition the conversion of numeric to string in this situation may present some need to check for missing leading "0"'s. You ether need to describe the data situation more completely or adjust your expectations (or both). ?as.POSIXct ?strptime -- David. Thanks for the quick reply David. What I need is a simple conversion that can say 8=08:00, 94500=09:45 and 10=10:00 and so on. I agree with you that the extra leading "0s" would need an extra check. I'm having some difficulty understanding what you want but see if this gets you further: > example <-"070002,1 + 070002,0 + 070002,0 + 070003,1 + 070003,0 + 070003,0 + 070003,0 + 070003,0 + 100210,0 + 100210,0 + 100210,0 + 100210,0 + 100210,0 + 100210,0 + 100210,0" > timedf <- read.table(textConnection(example), colClasses=c("character", "numeric"), sep=",", header=FALSE) > str(timedf) 'data.frame': 15 obs. of 2 variables: $ V1: chr "070002" "070002" "070002" "070003" ... $ V2: num 1 0 0 1 0 0 0 0 0 0 ... > as.POSIXct(timedf$V1, format="%H%M%S", origin="1970-01-01") [1] "2010-10-19 07:00:02 EDT" "2010-10-19 07:00:02 EDT" [3] "2010-10-19 07:00:02 EDT" "2010-10-19 07:00:03 EDT" [5] "2010-10-19 07:00:03 EDT" "2010-10-19 07:00:03 EDT" [7] "2010-10-19 07:00:03 EDT" "2010-10-19 07:00:03 EDT" [9] "2010-10-19 10:02:10 EDT" "2010-10-19 10:02:10 EDT" [11] "2010-10-19 10:02:10 EDT" "2010-10-19 10:02:10 EDT" [13] "2010-10-19 10:02:10 EDT" "2010-10-19 10:02:10 EDT" [15] "2010-10-19 10:02:10 EDT" The data situation is the following: I have several thousands of observations each day and I want to average them out throughout bins of a specified size (either 15 or 5 minutes). That was not clear to me. The phrase "average them out throughout bins of a specified size..." is not an unambiguous operation. This needs a good example that provides sample input and also expected output. An example of the data follows, where the first column is the time and the second represents seconds between different events. Notice that I read them in as character variables which preserved the leading zeroes. example.txt 070002,1 070002,0 070002,0 070003,1 070003,0 070003,0 070003,0 070003,0 ... 100210,0 100210,0 100210,0 100210,0 100210,0 100210,0 100210,0 ... -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002358.html Sent from the R help mailing list archive at Nabble.com. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
David Winsemius wrote: > > > You seen to be under the mistaken impression that the internal > representation of DateTime classes of 08:00 would be 8. Since the > internal representation of time is in seconds, the even number hours > would be at integer multiples of 60*60. In addition the conversion of > numeric to string in this situation may present some need to check for > missing leading "0"'s. You ether need to describe the data situation > more completely or adjust your expectations (or both). > > ?as.POSIXct > ?strptime > > -- > David. > > Thanks for the quick reply David. What I need is a simple conversion that can say 8=08:00, 94500=09:45 and 10=10:00 and so on. I agree with you that the extra leading "0s" would need an extra check. The data situation is the following: I have several thousands of observations each day and I want to average them out throughout bins of a specified size (either 15 or 5 minutes). An example of the data follows, where the first column is the time and the second represents seconds between different events. example.txt 070002,1 070002,0 070002,0 070003,1 070003,0 070003,0 070003,0 070003,0 ... 100210,0 100210,0 100210,0 100210,0 100210,0 100210,0 100210,0 ... -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002358.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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.
Re: [R] Chron object in time series plot
On Oct 19, 2010, at 11:25 AM, Manta wrote: Dear R users, I have the following script to create bins of specified time intervals bin_end=60/bin_size bin_size=bin_size*100 h=seq(07,18,by=1) breaks=c() for (i in h) { for (j in 0:(bin_end-1)) { value=i+(bin_size)*j breaks=append(breaks,value) } } I would like to plot then using the time as x-axis. I tried the following prova=zoo(myseries,times(breaks)) but of course I got the plot with the time as 8, 9, 10 and so on. I would like only 08:00, 09:00 and so on (maybe also the half hours). How to do it? You seen to be under the mistaken impression that the internal representation of DateTime classes of 08:00 would be 8. Since the internal representation of time is in seconds, the even number hours would be at integer multiples of 60*60. In addition the conversion of numeric to string in this situation may present some need to check for missing leading "0"'s. You ether need to describe the data situation more completely or adjust your expectations (or both). ?as.POSIXct ?strptime -- David. Thanks for your help, Marco -- View this message in context: http://r.789695.n4.nabble.com/Chron-object-in-time-series-plot-tp3002285p3002285.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list 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. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list 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.