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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:16:39+00:00 2026-06-12T10:16:39+00:00

I have a zoo object that contains velocity data from two different points (V1

  • 0

I have a zoo object that contains velocity data from two different points (V1 and V2), as well as particle Data from the same two points. The distance between the two points is 170m.

Date<- as.POSIXct("2012-01-01 08:00:00") + 1:120
V1<-rnorm(200,mean=5) #Velocity in m/sec
R<-rnorm(4,mean=3)
V2<-V1+R #Velocity in m/sec
Data1<-rnorm(200, mean=20)
Data2<-rnorm(200, mean=25)
V<-data.frame(V1,V2,Data1,Data2)
z<-zoo(as.matrix(V),order.by=Date)
L<-170 #Length =170m

If I average the velocity data

z$Avg_Vel<-rowMeans(z[,1:2])

I should have a pretty good idea of how fast the particles are traveling, and since I know the distance I should have a good idea of how long it is taking the particles to travel from Point 1 to Point 2 during the course of the time series.

z$Off<-L/z$Avg_Vel

But I cant figure out how to offset my zoo object to account for the time delay it takes for particles to travel between the two points. So if I am interested in finding the difference between Data 1 and Data 2, I don’t want to do

Diff<-z$Data1-z$Data2

As this does not include the offset

If it takes 2 minutes for the particles to travel from point 1 to point 2, than I would want

Diff<-z$Data1-z$Data2(+2min)

So that I am looking at the difference between Data1 at time x, and Data2 at time x+2min

To clarify in response to an answer, the end result would be a rolling offset. So that

  Offset<-z$Off

Looking at this kind of Offset

round(as.numeric(z$Off))

The result would look like this

1 Diff<- Diff<-z$Data1-z$Data2(+22 sec)
2 Diff<- Diff<-z$Data1-z$Data2(+23 sec)
3 Diff<- Diff<-z$Data1-z$Data2(+32 sec)..........
  • 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-12T10:16:40+00:00Added an answer on June 12, 2026 at 10:16 am

    This is a way to include an offset:

    offset <- 120 # 2 minutes in seconds
    
    ix <- index(z) + offset # new time index
    

    Calculate the difference with a 2-minute offset:

    z$Data1[rev(index(z) %in% ix)] -
     as.numeric(z$Data2[index(z) %in% ix])
    

    Your example time series is too short for an offset of 2 minutes. I tested it with a 1-minute offset instead (offset = 60).


    If you want to use a vector of offsets, use this:

    offsets <- sample(1:5, nrow(z), TRUE) # some example offsets (in ms)
    # alternatively you could use:
    # round(as.numeric(z$Off))
    
    ixs <- index(z) + offsets
    
    ixs_num <- match(ixs, index(z), nomatch = NA)
    
    z$Data1[seq(length(ixs_num))[!is.na(ixs_num)]] -
     as.numeric(z$Data2)[na.omit(ixs_num)]
    

    Note. This procedure works for both positive and negative offsets.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a zoo object in R that has daily data and is missing
I have a zoo object oi.zoo with weekly data. I would like to sooth
I have a zoo with daily data that looks like this: > head(almorol) 1973-10-02
I have some imported csv data that I have turned into an xts object.
I have some data that looks a bit like this: require(zoo) X <- rbind(c(date='20111001',
Suppose I have a monthly series of zoo data with signals from the set
I have a yearmon object: require(zoo) date1 <- as.yearmon(Mar 2012, %b %Y) class(date1) #
I have 82 .csv files, each of them a zoo object, with the following
I have two variables, the first is 1D flow vector containing 230 data and
I want to rbind.zoo two zoo object together. When I was testing I came

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.