I have just started using R for my PhD. I am importing my data from Excel via notepad into Word. Unfortunately, my data has many missing values. I have put '.' and this allowed me to import the data into R. However, I now want to interpolate these missing values. Please can someone give me some pointers as to the method/code I could use? Thankyou, Lillian.
On Mon, 6 Dec 2004 15:26:40 -0000 (GMT), nhy303 at abdn.ac.uk wrote :>I have just started using R for my PhD. I am importing my data from Excel >via notepad into Word. Unfortunately, my data has many missing values. I >have put '.' and this allowed me to import the data into R. However, I >now want to interpolate these missing values. Please can someone give me >some pointers as to the method/code I could use?The approx() function does linear interpolation. For example:> x <- 1:10 > y <- c(1, NA, 3, NA, NA, 2, NA, NA, NA, NA) > > approx(x, y, xout = x)$x [1] 1 2 3 4 5 6 7 8 9 10 $y [1] 1.000000 2.000000 3.000000 2.666667 2.333333 2.000000 NA NA [9] NA NA To get it to extrapolate those values at the end, you could try "rule = 2", but this might not do what you want... Duncan Murdoch
about the way you import your data in R : if you have a large data set in EXCEL, you should rather save it directly in EXCEL in csv format with tab or ";" separator for instance, leting your missing value blank or empty cells. ->then with ?read.table or ?read.csv, you should not have trouble to import your data (see option in help pages). na.string option will convert for you your missing value in NA. you could also do it directly from excel to R : cran.r-project.org/doc/manuals/R-data.pdf for more info yves Magliulo, PARIS Le lun 06/12/2004 ?? 16:26, nhy303 at abdn.ac.uk a ??crit :> I have just started using R for my PhD. I am importing my data from Excel > via notepad into Word. Unfortunately, my data has many missing values. I > have put '.' and this allowed me to import the data into R. However, I > now want to interpolate these missing values. Please can someone give me > some pointers as to the method/code I could use? > > Thankyou, > > Lillian. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >