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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:46:54+00:00 2026-06-16T01:46:54+00:00

I have database with time data. I want to interpolate the data to mach

  • 0

I have database with time data. I want to interpolate the data to mach e specific time step.

Id  Time                    humid   humtemp prtemp  press       t
1   2012-01-21 18:41:50     47.7    14.12   13.870  1005.70     -0.05277778
1   2012-01-21 18:46:43     44.5    15.37   15.100  1005.20     0.02861111
1   2012-01-21 18:51:35     43.2    15.88   15.576  1005.10     0.10972222
1   2012-01-21 18:56:28     42.5    16.17   15.833  1004.90     0.19111111
1   2012-01-21 19:01:21     42.2    16.31   15.986  1004.80     0.27250000
1   2012-01-21 19:06:14     41.8    16.47   16.118  1004.60     0.35388889
1   2012-01-21 19:11:07     41.6    16.51   16.177  1004.60     0.43527778

I want to obtain data with below time step doing interpolation.

    Id                 Time       humid    humtemp prtemp  press        t   
    1   2012-01-21 18:45:00 ....    ...     .....   ....        ....
    1   2012-01-21 18:50:00 ....    
    1   2012-01-21 18:55:00 ....    
    1   2012-01-21 19:00:00 ....    
    1   2012-01-21 19:05:00 ....    
    1   2012-01-21 19:10:00 ....    

I tried with diffrent method but I didn’t find the solution. For example I create zoo object.

   z <- zoo(MTS01m,order.by=MTS01m$Time)
   tstart2<-asP("2012-01-21 18:45:00")
   Ts<-1*60
   y <- merge(z, zoo(order.by=seq(tstart2, end(z), by=Ts)))
   xa <- na.approx(y)
   xs <- na.spline(y)

but error occur:

   Errore in approx(x[!na], y[!na], xout, ...) : 
   need at least two non-NA values to interpolate
   Inoltre: Warning message:
   In xy.coords(x, y) : si è prodotto un NA per coercizione

I create a secundary index t that start where I want to have data, but I don’t know how to use thid index.

Have you any suggestion?

  • 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-16T01:46:56+00:00Added an answer on June 16, 2026 at 1:46 am

    Try this (assuming your time index is POSIXct):

    library(zoo)
    st <- as.POSIXct("2012-01-21 18:45")
    g <- seq(st, end(z), by = "15 min") # grid
    na.approx(z, xout = g)
    

    See ?na.approx.zoo for more info.

    Note: Since the question did not provide the data in reproducible form we do so here:

    Lines <- "Id date Time humid humtemp prtemp press t1
    1   2012-01-21 18:41:50     47.7    14.12   13.870  1005.70     -0.05277778
    1   2012-01-21 18:46:43     44.5    15.37   15.100  1005.20     0.02861111
    1   2012-01-21 18:51:35     43.2    15.88   15.576  1005.10     0.10972222
    1   2012-01-21 18:56:28     42.5    16.17   15.833  1004.90     0.19111111
    1   2012-01-21 19:01:21     42.2    16.31   15.986  1004.80     0.27250000
    1   2012-01-21 19:06:14     41.8    16.47   16.118  1004.60     0.35388889
    1   2012-01-21 19:11:07     41.6    16.51   16.177  1004.60     0.43527778"
    
    library(zoo)
    z <- read.zoo(text = Lines, header = TRUE, index = 2:3, tz = "")
    st <- as.POSIXct("2012-01-21 18:45")
    g <- seq(st, end(z), by = "15 min") # grid
    na.approx(z, xout = g)
    

    giving:

                        Id    humid  humtemp   prtemp    press            t1
    2012-01-21 18:45:00  1 45.62491 14.93058 14.66761 1005.376 -1.501706e-09
    2012-01-21 19:00:00  1 42.28294 16.27130 15.94370 1004.828  2.500000e-01
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have time saved in database like 7:30pm as a varchar field. I want
We have an application that takes real time data and inserts it into database.
I have a database in data center, which is running MySQL, and I want
We have a database with the time related data in it. As you can
I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How
I have a database server in Europe/London time zone and my web server in
I have a database table full of time points and experimental values at those
I have the following entry in my database: t.time :my_time_stamp In my controller I
I have a database in MySQL which have entries of time. There are more
I have a database with a large number of records that are Date/Time stamped.

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.