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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:01:34+00:00 2026-05-18T05:01:34+00:00

I have two data frames. The one consists of three variables, namely date, strike

  • 0

I have two data frames.
The one consists of three variables, namely “date”, “strike” and “vol” with 20 observations a day, 100 a month and 1200 a year (in trading days), which looks like this

Date         Price       Vol
2008-09-01   20          0.2
2008-09-01   30          0.5
...

So for each month I have certain values for price and vol, ranging from 10 to 40, 0.1 to 0.7, respectively.
The second one includes interpolated values from the first one. So I do not have the date anymore, however small steps for the other variables:

  Price       Vol
   20          0.2
   21          0.21
   22          0.24
   30          0.5

So, while one frame shows values in a discrete time, the other one is more or less of continuous nature.
Now my question: how is it possible to tell R to merge the second data frame into the first one, taking over the dates for the continuous prices/vols between the two discrete ones, to get to something like this:

Date         Price       Vol
2008-09-01   20          0.2
2008-09-01   21          0.21
2008-09-01   22          0.24
...
2008-09-01   30          0.5

I just cannot figure out how to do it. I always ended up with NA values for the dates which are no longer in ascending order.

Thank you very much for your support
Dani

  • 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-18T05:01:35+00:00Added an answer on May 18, 2026 at 5:01 am

    I totally missed the point with the first post. This one does the date. But I agree with Shane that unless some downstream function requires data frames, then a time series is a good idea.

    A <- data.frame(date=rep("2001-05-25", 2), price=c(20, 30), vol=c(0.2, 0.5))
    B <- data.frame(price=seq(min(A$price), max(A$price), by=1))
    C <- merge(A, B, all=TRUE)
    index <- which(!is.na(C$vol))
    for (i in seq(nrow(A))[-1]) {
        C$date[index[i-1]:index[i]] <- rep(A$date[i-1], A$price[i] - A$price[i-1] + 1)
        C$vol[index[i-1]:index[i]] <- seq(A$vol[i-1], A$vol[i], length=(A$price[i] - A$price[i-1] + 1))
    }
    ans <- C[, c(2, 1, 3)]
    
     ans 
             date price  vol
    1  2001-05-25    20 0.20
    2  2001-05-25    21 0.23
    3  2001-05-25    22 0.26
    4  2001-05-25    23 0.29
    5  2001-05-25    24 0.32
    6  2001-05-25    25 0.35
    7  2001-05-25    26 0.38
    8  2001-05-25    27 0.41
    9  2001-05-25    28 0.44
    10 2001-05-25    29 0.47
    11 2001-05-25    30 0.50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two data.frames in R, one of which has two columns and of
I have two processes one will query other for data.There will be huge amount
I am trying to merge several data.frames into one data.frame . Since I have
I have to merge to data frames in R. The two data frames share
I have a data frame with 251 observations and 45 variables. There are 6
I am using R and I have two data frames: carrots and cucumbers. Each
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two files (f1 and f2) containing some text (or binary data). How
I have two projects, the DLL project which has all my logic and data
I have a two dimensional array that I need to load data into. I

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.