Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8874315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:41:21+00:00 2026-06-14T18:41:21+00:00

I’ve got some large data.frames with POSIXct columns. time longitude latitude 1 2012-10-28 23:01:00

  • 0

I’ve got some large data.frames with POSIXct columns.

                 time longitude latitude
1 2012-10-28 23:01:00  16.42125 52.37832
2 2012-10-28 23:02:00  16.42125 52.37832
3 2012-10-28 23:03:00  16.42127 52.37832
...

For compatibility reasons, I store the time values instead of the row indices in some places. How can I obtain the (always consecutive) rows with those time values?

With indices, I’d do this:

indices <- 1:3
rows <- dat[indices,]

But with time:

times <- dat$time[1:3]
rows <- ???

What’s an efficient solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T18:41:22+00:00Added an answer on June 14, 2026 at 6:41 pm

    Switch to package xts. Here us a random example for you:

    R> dat <- xts(as.matrix(data.frame(long=rnorm(20, 16, 0.1), 
    +                                  lat=rnorm(20, 52, 0.1))),
    +             order.by=ISOdatetime(2012,10,28,23,00,00)+seq(1,20))
    R> dat
                           long     lat
    2012-10-28 23:00:01 16.1100 52.0176
    2012-10-28 23:00:02 15.7947 52.1227
    2012-10-28 23:00:03 15.9632 52.1097
    2012-10-28 23:00:04 16.1478 51.8562
    2012-10-28 23:00:05 16.0800 52.0969
    2012-10-28 23:00:06 15.9444 51.9217
    2012-10-28 23:00:07 16.1291 52.1710
    2012-10-28 23:00:08 16.1400 52.0243
    2012-10-28 23:00:09 15.8718 52.0717
    2012-10-28 23:00:10 16.0093 51.9953
    2012-10-28 23:00:11 15.9821 52.1891
    2012-10-28 23:00:12 16.0326 51.9598
    2012-10-28 23:00:13 15.9243 51.9634
    2012-10-28 23:00:14 15.9498 52.1015
    2012-10-28 23:00:15 16.1454 51.9398
    2012-10-28 23:00:16 15.9191 51.8936
    2012-10-28 23:00:17 16.0541 51.7999
    2012-10-28 23:00:18 15.7676 52.0641
    2012-10-28 23:00:19 16.1154 52.0178
    2012-10-28 23:00:20 16.1094 51.9573
    R>
    

    You can easily create xts objects from existing ones, read from file, etc pp. Lots of examples here too.

    Now you can use the nice subsetting:

    R> dat["2012-10-28 23:00:10/2012-10-28 23:00:14"]
                           long     lat
    2012-10-28 23:00:10 16.0093 51.9953
    2012-10-28 23:00:11 15.9821 52.1891
    2012-10-28 23:00:12 16.0326 51.9598
    2012-10-28 23:00:13 15.9243 51.9634
    2012-10-28 23:00:14 15.9498 52.1015
    R> 
    

    or even in shorthand:

    R> dat["T23:00:10/T23:00:14"]
                           long     lat
    2012-10-28 23:00:10 16.0093 51.9953
    2012-10-28 23:00:11 15.9821 52.1891
    2012-10-28 23:00:12 16.0326 51.9598
    2012-10-28 23:00:13 15.9243 51.9634
    2012-10-28 23:00:14 15.9498 52.1015
    R> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.