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 455745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:24:07+00:00 2026-05-12T22:24:07+00:00

Data I’m importing describes numeric measurements taken at various locations for more or less

  • 0

Data I’m importing describes numeric measurements taken at various locations for more or less evenly spread timestamps. sometimes this “evenly spread” is not really true and I have to discard some of the values, it’s not that important which one, as long as I have one value for each timestamp for each location.

what I do with the data? I add it to a result data.frame. There I have a timestamp column and the values in the timestamp column, they are definitely evenly spaced according to the step.

timestamps <- ceiling(as.numeric((timestamps-epoch)*24*60/step))*step*60 + epoch
result[result$timestamp %in% timestamps, columnName] <- values

This does NOT work when I have timestamps that fall in the same time step. This is an example:

> data.frame(ts=timestamps, v=values)
                   ts         v
1 2009-09-30 10:00:00 -2.081609
2 2009-09-30 10:04:18 -2.079778
3 2009-09-30 10:07:47 -2.113531
4 2009-09-30 10:09:01 -2.124716
5 2009-09-30 10:15:00 -2.102117
6 2009-09-30 10:27:56 -2.093542
7 2009-09-30 10:30:00 -2.092626
8 2009-09-30 10:45:00 -2.086339
9 2009-09-30 11:00:00 -2.080144
> data.frame(ts=ceiling(as.numeric((timestamps-epoch)*24*60/step))*step*60+epoch,
+ v=values)
                   ts         v
1 2009-09-30 10:00:00 -2.081609
2 2009-09-30 10:15:00 -2.079778
3 2009-09-30 10:15:00 -2.113531
4 2009-09-30 10:15:00 -2.124716
5 2009-09-30 10:15:00 -2.102117
6 2009-09-30 10:30:00 -2.093542
7 2009-09-30 10:30:00 -2.092626
8 2009-09-30 10:45:00 -2.086339
9 2009-09-30 11:00:00 -2.080144

in Python I would (mis)use a dictionary to achieve what I need:

dict(zip(timestamps, values)).items()

returns a list of pairs where the first coordinate is unique.

in R I don’t know how to do it in a compact and efficient way.

  • 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-05-12T22:24:07+00:00Added an answer on May 12, 2026 at 10:24 pm

    I would use subset combined with duplicated to filter non-unique timestamps in the second data frame:

    R> df_ <- read.table(textConnection('
                         ts         v
    1 "2009-09-30 10:00:00" -2.081609
    2 "2009-09-30 10:15:00" -2.079778
    3 "2009-09-30 10:15:00" -2.113531
    4 "2009-09-30 10:15:00" -2.124716
    5 "2009-09-30 10:15:00" -2.102117
    6 "2009-09-30 10:30:00" -2.093542
    7 "2009-09-30 10:30:00" -2.092626
    8 "2009-09-30 10:45:00" -2.086339
    9 "2009-09-30 11:00:00" -2.080144
    '), as.is=TRUE, header=TRUE)
    
    R> subset(df_, !duplicated(ts))
                       ts      v
    1 2009-09-30 10:00:00 -2.082
    2 2009-09-30 10:15:00 -2.080
    6 2009-09-30 10:30:00 -2.094
    8 2009-09-30 10:45:00 -2.086
    9 2009-09-30 11:00:00 -2.080
    

    Update: To select a specific value you can use aggregate

    aggregate(df_$v, by=list(df_$ts), function(x) x[1])  # first value
    aggregate(df_$v, by=list(df_$ts), function(x) tail(x, n=1))  # last value
    aggregate(df_$v, by=list(df_$ts), function(x) max(x))  # max value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Data class, in this question scope, is a class with more public properties than
Data: a dependency list, already verified to be acyclic. So here, 'a' depends on
Data table structure is: id1,id2,id3,id4,... (some other fields). I want to create summary query
data: id bb 1 14,35 2 5,11,12,125,36 3 3,23,45,15,1 4 651 5 5,1,6 6
Data Access Objects (DAOs) are a common design pattern, and recommended by Sun. But
Data from another system is replicated into a SQL Server 2005 database in real-time
Data comes in by email as a zipped file. The Java solution we wrote
.data VALS: .half 0xbead, 0xface RES: .space 4 .text la $t0,VALS lh $t1,($t0) lhu
data GroceryItem = CartItem ItemName Price Quantity | StockItem ItemName Price Quantity makeGroceryItem ::
Data-aware controls can be linked to datasets to display data contained in fields in

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.