[R] Change data frame to time series data

Rui Barradas ru|pb@rr@d@@ @end|ng |rom @@po@pt
Wed Oct 2 17:39:22 CEST 2024


Às 16:20 de 02/10/2024, roslinazairimah zakaria escreveu:
> Let say, this is my data and I want to extract from 2014-01-01
> 00:00:00 to 2014-01-01
> 16:30:00
> 
>> dput(head(dt_ts,1000))
> 
> structure(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, 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, 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, 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,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L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
> 1L, 1L, 1L, 1L, 1L, 1L, 1L, 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), class = c("xts",
> "zoo"), index = structure(c(1388505600, 1388505660, 1388505720,
> 1388505780, 1388505840, 1388505900, 1388505960, 1388506020, 1388506080,
> 1388506140, 1388506200, 1388506260, 1388506320, 1388506380, 1388506440,
> 1388506500, 1388506560, 1388506620, 1388506680, 1388506740, 1388506800,
> 1388506860, 1388506920, 1388506980, 1388507040, 1388507100, 1388507160,
> 1388507220, 1388507280, 1388507340, 1388507400, 1388507460, 1388507520,
> 1388507580, 1388507640, 1388507700, 1388507760, 1388507820, 1388507880,
> 1388507940, 1388508000, 1388508060, 1388508120, 1388508180, 1388508240,
> 1388508300, 1388508360, 1388508420, 1388508480, 1388508540, 1388508600,
> 1388508660, 1388508720, 1388508780, 1388508840, 1388508900, 1388508960,
> 1388509020, 1388509080, 1388509140, 1388509200, 1388509260, 1388509320,
> 1388509380, 1388509440, 1388509500, 1388509560, 1388509620, 1388509680,
> 1388509740, 1388509800, 1388509860, 1388509920, 1388509980, 1388510040,
> 1388510100, 1388510160, 1388510220, 1388510280, 1388510340, 1388510400,
> 1388510460, 1388510520, 1388510580, 1388510640, 1388510700, 1388510760,
> 1388510820, 1388510880, 1388510940, 1388511000, 1388511060, 1388511120,
> 1388511180, 1388511240, 1388511300, 1388511360, 1388511420, 1388511480,
> 1388511540, 1388511600, 1388511660, 1388511720, 1388511780, 1388511840,
> 1388511900, 1388511960, 1388512020, 1388512080, 1388512140, 1388512200,
> 1388512260, 1388512320, 1388512380, 1388512440, 1388512500, 1388512560,
> 1388512620, 1388512680, 1388512740, 1388512800, 1388512860, 1388512920,
> 1388512980, 1388513040, 1388513100, 1388513160, 1388513220, 1388513280,
> 1388513340, 1388513400, 1388513460, 1388513520, 1388513580, 1388513640,
> 1388513700, 1388513760, 1388513820, 1388513880, 1388513940, 1388514000,
> 1388514060, 1388514120, 1388514180, 1388514240, 1388514300, 1388514360,
> 1388514420, 1388514480, 1388514540, 1388514600, 1388514660, 1388514720,
> 1388514780, 1388514840, 1388514900, 1388514960, 1388515020, 1388515080,
> 1388515140, 1388515200, 1388515260, 1388515320, 1388515380, 1388515440,
> 1388515500, 1388515560, 1388515620, 1388515680, 1388515740, 1388515800,
> 1388515860, 1388515920, 1388515980, 1388516040, 1388516100, 1388516160,
> 1388516220, 1388516280, 1388516340, 1388516400, 1388516460, 1388516520,
> 1388516580, 1388516640, 1388516700, 1388516760, 1388516820, 1388516880,
> 1388516940, 1388517000, 1388517060, 1388517120, 1388517180, 1388517240,
> 1388517300, 1388517360, 1388517420, 1388517480, 1388517540, 1388517600,
> 1388517660, 1388517720, 1388517780, 1388517840, 1388517900, 1388517960,
> 1388518020, 1388518080, 1388518140, 1388518200, 1388518260, 1388518320,
> 1388518380, 1388518440, 1388518500, 1388518560, 1388518620, 1388518680,
> 1388518740, 1388518800, 1388518860, 1388518920, 1388518980, 1388519040,
> 1388519100, 1388519160, 1388519220, 1388519280, 1388519340, 1388519400,
> 1388519460, 1388519520, 1388519580, 1388519640, 1388519700, 1388519760,
> 1388519820, 1388519880, 1388519940, 1388520000, 1388520060, 1388520120,
> 1388520180, 1388520240, 1388520300, 1388520360, 1388520420, 1388520480,
> 1388520540, 1388520600, 1388520660, 1388520720, 1388520780, 1388520840,
> 1388520900, 1388520960, 1388521020, 1388521080, 1388521140, 1388521200,
> 1388521260, 1388521320, 1388521380, 1388521440, 1388521500, 1388521560,
> 1388521620, 1388521680, 1388521740, 1388521800, 1388521860, 1388521920,
> 1388521980, 1388522040, 1388522100, 1388522160, 1388522220, 1388522280,
> 1388522340, 1388522400, 1388522460, 1388522520, 1388522580, 1388522640,
> 1388522700, 1388522760, 1388522820, 1388522880, 1388522940, 1388523000,
> 1388523060, 1388523120, 1388523180, 1388523240, 1388523300, 1388523360,
> 1388523420, 1388523480, 1388523540, 1388523600, 1388523660, 1388523720,
> 1388523780, 1388523840, 1388523900, 1388523960, 1388524020, 1388524080,
> 1388524140, 1388524200, 1388524260, 1388524320, 1388524380, 1388524440,
> 1388524500, 1388524560, 1388524620, 1388524680, 1388524740, 1388524800,
> 1388524860, 1388524920, 1388524980, 1388525040, 1388525100, 1388525160,
> 1388525220, 1388525280, 1388525340, 1388525400, 1388525460, 1388525520,
> 1388525580, 1388525640, 1388525700, 1388525760, 1388525820, 1388525880,
> 1388525940, 1388526000, 1388526060, 1388526120, 1388526180, 1388526240,
> 1388526300, 1388526360, 1388526420, 1388526480, 1388526540, 1388526600,
> 1388526660, 1388526720, 1388526780, 1388526840, 1388526900, 1388526960,
> 1388527020, 1388527080, 1388527140, 1388527200, 1388527260, 1388527320,
> 1388527380, 1388527440, 1388527500, 1388527560, 1388527620, 1388527680,
> 1388527740, 1388527800, 1388527860, 1388527920, 1388527980, 1388528040,
> 1388528100, 1388528160, 1388528220, 1388528280, 1388528340, 1388528400,
> 1388528460, 1388528520, 1388528580, 1388528640, 1388528700, 1388528760,
> 1388528820, 1388528880, 1388528940, 1388529000, 1388529060, 1388529120,
> 1388529180, 1388529240, 1388529300, 1388529360, 1388529420, 1388529480,
> 1388529540, 1388529600, 1388529660, 1388529720, 1388529780, 1388529840,
> 1388529900, 1388529960, 1388530020, 1388530080, 1388530140, 1388530200,
> 1388530260, 1388530320, 1388530380, 1388530440, 1388530500, 1388530560,
> 1388530620, 1388530680, 1388530740, 1388530800, 1388530860, 1388530920,
> 1388530980, 1388531040, 1388531100, 1388531160, 1388531220, 1388531280,
> 1388531340, 1388531400, 1388531460, 1388531520, 1388531580, 1388531640,
> 1388531700, 1388531760, 1388531820, 1388531880, 1388531940, 1388532000,
> 1388532060, 1388532120, 1388532180, 1388532240, 1388532300, 1388532360,
> 1388532420, 1388532480, 1388532540, 1388532600, 1388532660, 1388532720,
> 1388532780, 1388532840, 1388532900, 1388532960, 1388533020, 1388533080,
> 1388533140, 1388533200, 1388533260, 1388533320, 1388533380, 1388533440,
> 1388533500, 1388533560, 1388533620, 1388533680, 1388533740, 1388533800,
> 1388533860, 1388533920, 1388533980, 1388534040, 1388534100, 1388534160,
> 1388534220, 1388534280, 1388534340, 1388534400, 1388534460, 1388534520,
> 1388534580, 1388534640, 1388534700, 1388534760, 1388534820, 1388534880,
> 1388534940, 1388535000, 1388535060, 1388535120, 1388535180, 1388535240,
> 1388535300, 1388535360, 1388535420, 1388535480, 1388535540, 1388535600,
> 1388535660, 1388535720, 1388535780, 1388535840, 1388535900, 1388535960,
> 1388536020, 1388536080, 1388536140, 1388536200, 1388536260, 1388536320,
> 1388536380, 1388536440, 1388536500, 1388536560, 1388536620, 1388536680,
> 1388536740, 1388536800, 1388536860, 1388536920, 1388536980, 1388537040,
> 1388537100, 1388537160, 1388537220, 1388537280, 1388537340, 1388537400,
> 1388537460, 1388537520, 1388537580, 1388537640, 1388537700, 1388537760,
> 1388537820, 1388537880, 1388537940, 1388538000, 1388538060, 1388538120,
> 1388538180, 1388538240, 1388538300, 1388538360, 1388538420, 1388538480,
> 1388538540, 1388538600, 1388538660, 1388538720, 1388538780, 1388538840,
> 1388538900, 1388538960, 1388539020, 1388539080, 1388539140, 1388539200,
> 1388539260, 1388539320, 1388539380, 1388539440, 1388539500, 1388539560,
> 1388539620, 1388539680, 1388539740, 1388539800, 1388539860, 1388539920,
> 1388539980, 1388540040, 1388540100, 1388540160, 1388540220, 1388540280,
> 1388540340, 1388540400, 1388540460, 1388540520, 1388540580, 1388540640,
> 1388540700, 1388540760, 1388540820, 1388540880, 1388540940, 1388541000,
> 1388541060, 1388541120, 1388541180, 1388541240, 1388541300, 1388541360,
> 1388541420, 1388541480, 1388541540, 1388541600, 1388541660, 1388541720,
> 1388541780, 1388541840, 1388541900, 1388541960, 1388542020, 1388542080,
> 1388542140, 1388542200, 1388542260, 1388542320, 1388542380, 1388542440,
> 1388542500, 1388542560, 1388542620, 1388542680, 1388542740, 1388542800,
> 1388542860, 1388542920, 1388542980, 1388543040, 1388543100, 1388543160,
> 1388543220, 1388543280, 1388543340, 1388543400, 1388543460, 1388543520,
> 1388543580, 1388543640, 1388543700, 1388543760, 1388543820, 1388543880,
> 1388543940, 1388544000, 1388544060, 1388544120, 1388544180, 1388544240,
> 1388544300, 1388544360, 1388544420, 1388544480, 1388544540, 1388544600,
> 1388544660, 1388544720, 1388544780, 1388544840, 1388544900, 1388544960,
> 1388545020, 1388545080, 1388545140, 1388545200, 1388545260, 1388545320,
> 1388545380, 1388545440, 1388545500, 1388545560, 1388545620, 1388545680,
> 1388545740, 1388545800, 1388545860, 1388545920, 1388545980, 1388546040,
> 1388546100, 1388546160, 1388546220, 1388546280, 1388546340, 1388546400,
> 1388546460, 1388546520, 1388546580, 1388546640, 1388546700, 1388546760,
> 1388546820, 1388546880, 1388546940, 1388547000, 1388547060, 1388547120,
> 1388547180, 1388547240, 1388547300, 1388547360, 1388547420, 1388547480,
> 1388547540, 1388547600, 1388547660, 1388547720, 1388547780, 1388547840,
> 1388547900, 1388547960, 1388548020, 1388548080, 1388548140, 1388548200,
> 1388548260, 1388548320, 1388548380, 1388548440, 1388548500, 1388548560,
> 1388548620, 1388548680, 1388548740, 1388548800, 1388548860, 1388548920,
> 1388548980, 1388549040, 1388549100, 1388549160, 1388549220, 1388549280,
> 1388549340, 1388549400, 1388549460, 1388549520, 1388549580, 1388549640,
> 1388549700, 1388549760, 1388549820, 1388549880, 1388549940, 1388550000,
> 1388550060, 1388550120, 1388550180, 1388550240, 1388550300, 1388550360,
> 1388550420, 1388550480, 1388550540, 1388550600, 1388550660, 1388550720,
> 1388550780, 1388550840, 1388550900, 1388550960, 1388551020, 1388551080,
> 1388551140, 1388551200, 1388551260, 1388551320, 1388551380, 1388551440,
> 1388551500, 1388551560, 1388551620, 1388551680, 1388551740, 1388551800,
> 1388551860, 1388551920, 1388551980, 1388552040, 1388552100, 1388552160,
> 1388552220, 1388552280, 1388552340, 1388552400, 1388552460, 1388552520,
> 1388552580, 1388552640, 1388552700, 1388552760, 1388552820, 1388552880,
> 1388552940, 1388553000, 1388553060, 1388553120, 1388553180, 1388553240,
> 1388553300, 1388553360, 1388553420, 1388553480, 1388553540, 1388553600,
> 1388553660, 1388553720, 1388553780, 1388553840, 1388553900, 1388553960,
> 1388554020, 1388554080, 1388554140, 1388554200, 1388554260, 1388554320,
> 1388554380, 1388554440, 1388554500, 1388554560, 1388554620, 1388554680,
> 1388554740, 1388554800, 1388554860, 1388554920, 1388554980, 1388555040,
> 1388555100, 1388555160, 1388555220, 1388555280, 1388555340, 1388555400,
> 1388555460, 1388555520, 1388555580, 1388555640, 1388555700, 1388555760,
> 1388555820, 1388555880, 1388555940, 1388556000, 1388556060, 1388556120,
> 1388556180, 1388556240, 1388556300, 1388556360, 1388556420, 1388556480,
> 1388556540, 1388556600, 1388556660, 1388556720, 1388556780, 1388556840,
> 1388556900, 1388556960, 1388557020, 1388557080, 1388557140, 1388557200,
> 1388557260, 1388557320, 1388557380, 1388557440, 1388557500, 1388557560,
> 1388557620, 1388557680, 1388557740, 1388557800, 1388557860, 1388557920,
> 1388557980, 1388558040, 1388558100, 1388558160, 1388558220, 1388558280,
> 1388558340, 1388558400, 1388558460, 1388558520, 1388558580, 1388558640,
> 1388558700, 1388558760, 1388558820, 1388558880, 1388558940, 1388559000,
> 1388559060, 1388559120, 1388559180, 1388559240, 1388559300, 1388559360,
> 1388559420, 1388559480, 1388559540, 1388559600, 1388559660, 1388559720,
> 1388559780, 1388559840, 1388559900, 1388559960, 1388560020, 1388560080,
> 1388560140, 1388560200, 1388560260, 1388560320, 1388560380, 1388560440,
> 1388560500, 1388560560, 1388560620, 1388560680, 1388560740, 1388560800,
> 1388560860, 1388560920, 1388560980, 1388561040, 1388561100, 1388561160,
> 1388561220, 1388561280, 1388561340, 1388561400, 1388561460, 1388561520,
> 1388561580, 1388561640, 1388561700, 1388561760, 1388561820, 1388561880,
> 1388561940, 1388562000, 1388562060, 1388562120, 1388562180, 1388562240,
> 1388562300, 1388562360, 1388562420, 1388562480, 1388562540, 1388562600,
> 1388562660, 1388562720, 1388562780, 1388562840, 1388562900, 1388562960,
> 1388563020, 1388563080, 1388563140, 1388563200, 1388563260, 1388563320,
> 1388563380, 1388563440, 1388563500, 1388563560, 1388563620, 1388563680,
> 1388563740, 1388563800, 1388563860, 1388563920, 1388563980, 1388564040,
> 1388564100, 1388564160, 1388564220, 1388564280, 1388564340, 1388564400,
> 1388564460, 1388564520, 1388564580, 1388564640, 1388564700, 1388564760,
> 1388564820, 1388564880, 1388564940, 1388565000, 1388565060, 1388565120,
> 1388565180, 1388565240, 1388565300, 1388565360, 1388565420, 1388565480,
> 1388565540), tzone = "", tclass = c("POSIXct", "POSIXt")), dim = c(1000L,
> 1L))
> 
> 
> On Wed, Oct 2, 2024 at 11:03 PM Hasan Diwan <hasan.diwan using gmail.com> wrote:
> 
>> On Wed, 2 Oct 2024 at 07:53, roslinazairimah zakaria <roslinaump using gmail.com
>>>
>> wrote:
>>
>>> Next question, how do I delete the date from 16 December until 31
>> December
>>> 2014?
>>>
>>
>> Something like:
>> myData <- xtsObj[myData$date <  "2014-12-16" & myData$date > "2024-12-31"]
>> -- H
>>
>> --
>> OpenPGP: https://hasan.d8u.us/openpgp.asc
>> If you wish to request my time, please do so using
>> *bit.ly/hd1AppointmentRequest
>> <http://bit.ly/hd1AppointmentRequest>*.
>> Si vous voudriez faire connnaisance, allez a *bit.ly/hd1AppointmentRequest
>> <http://bit.ly/hd1AppointmentRequest>*.
>>
>> <https://sks-keyservers.net/pks/lookup?op=get&search=0xFEBAD7FFD041BBA1
>>> Sent
>> from my mobile device
>> Envoye de mon portable
>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> https://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 
Hello,

Use function index.


library(xts)

# extract from 2014-01-01 00:00:00
#           to 2014-01-01 16:30:00
from <- as.POSIXct("2014-01-01 00:00:00")
to <- as.POSIXct("2014-01-01 16:30:00")
i <- index(dt_ts) >= from & index(dt_ts) <= to
dt_ts[i]


Also, instead of copying&pasting the data, you can attach a file with 
extension .txt.

Hope this helps,

Rui Barradas



-- 
Este e-mail foi analisado pelo software antivírus AVG para verificar a presença de vírus.
www.avg.com



More information about the R-help mailing list