-2

I have a huge data set in the form of

           V1           V2         V3   V4     V5  V6
1      201005010000 201005010000  1.68 291.38  1   0
2      201005010000 201005010300  0.93 335.10  1   0
3      201005010000 201005010600  2.25  57.38  1   0
4      201005010000 201005010900  0.43  13.76  1   0
5      201005010000 201005011200  0.74 101.14  1   0

I am interested in interpolating it on an hour basis(it's for avery 3 hours). Data is also being updated after every six hours for next eight days. Thanks in advance.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
  • Please be more specific about your problem, provide some sample data (either make up your own or use `dput` on a subset of your own data) and be specific about the desired output. It will help us a bunch if you already show us what you did so far and what are the roadblocks you encountered along the way. See also http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example for tips on how to provide a good example (and rising the chance of getting a (good) answer). – Roman Luštrik Nov 16 '11 at 13:58
  • Voted to close as 'not a real question'. Because its not even an unreal question. Its not a question. You've got some data. You want to interpolate it. Good for you. Whaddayawantustodo? – Spacedman Nov 16 '11 at 14:10

1 Answers1

1

I think you are asking for interpolation of the variables V3 and V4 at equally spaced intervals between the V2 vector which is varying at increments of 300. This illustrates doing so for V3, but adding a similarly calculated interp-V4 would be trivial. (I haven't figured out what we are supposed to be doing with the information about updating.)

> a100 <- approxfun( y=dat$V3, x=dat$V2)
> intvec <- a100(seq(dat$V2[1], dat$V2[length(dat$V2)], by=100)
+ )
> intvec
 [1] 1.6800000 1.4300000 1.1800000 0.9300000 1.3700000 1.8100000 2.2500000
 [8] 1.6433333 1.0366667 0.4300000 0.5333333 0.6366667 0.7400000
> data.frame(V2 = seq(dat$V2[1], dat$V2[length(dat$V2)], by=100),
+            V3 =intvec)
             V2        V3
1  201005010000 1.6800000
2  201005010100 1.4300000
3  201005010200 1.1800000
4  201005010300 0.9300000
5  201005010400 1.3700000
6  201005010500 1.8100000
7  201005010600 2.2500000
8  201005010700 1.6433333
9  201005010800 1.0366667
10 201005010900 0.4300000
11 201005011000 0.5333333
12 201005011100 0.6366667
13 201005011200 0.7400000
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • thanks for your prompt reply. But v2 is in date. 2010-05-01 00:00 and if i keep adding 100 it is giving hours more than 24:00. 201005010000 201005021500 3.82 108.29 1 0 201005010000 201005021800 1.59 148.42 1 0 if your see the data set the after 21:00 h the date changes. i hope i am able to clarify myself. 201005010000 201005022100 1.29 166.43 1 0 201005010000 201005030000 1.72 177.14 1 0 201005010000 201005030300 1.78 191.98 1 0 201005010000 201005030600 0.13 118.76 1 0 201005010000 201005030900 2.15 105.28 1 0 – abcdef ghijk Nov 16 '11 at 15:09
  • V2 is definitely not an R Date class variable yet.You can choose the increment step to suit you needs. I was just giving you two interpolated points between the values you offered. Make modifications as needed. – IRTFM Nov 16 '11 at 15:56