0

I have some missing data like :--

             1995 1996 1997 1998 1999

             4    NA   NA   5    NA

what i want to do here is this :-

            1995 1996      1997      1998 1999

            4    4.3300001 4.6700001 5    5.0000002

Iam able to write code for the above interpolation (missing and stale data) but........

The data i input is not always clean. It might come as

            1995  1996 1997 1998   1999

            4.032 NA   NA   5.134  5.0000002

This might interrupt with the precision of the interpolated numbers (who go to 7 decimal places)

So i wanted to round off the data before running my interpolation function.

I tried rounding off (doesn't work)

How to round a long decimal place cell in R?

as.numeric increases the precision of character digits?

I tried multiplying with 100, rounding to 0 decimal places and then dividing by 100, (doesn't work) (for some reason every division causes data to go n decimal places)

I also tried using (options = digits) because that works on all digits and not only on digits to the right of the decimal place.

Can anyone help me out here?

Arvinth Kumar
  • 964
  • 3
  • 15
  • 32
  • What exactly doesn't work? When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Show the code you tried and tell us how you "tested" it so we can do the same. – MrFlick Mar 27 '18 at 19:36
  • Do you really need precision up to 7 digits? – bala83 Mar 27 '18 at 20:23
  • Yes. Though it works fine if i don't include the options(digits) command at all. – Arvinth Kumar Mar 29 '18 at 15:08

0 Answers0