Re: [R] Need a faster function to replace missing data

2009-05-26 Thread Tim Clark
jim holtman > Subject: Re: [R] Need a faster function to replace missing data > To: "Tim Clark" > Cc: r-help@r-project.org > Date: Friday, May 22, 2009, 4:59 PM > Here is a modification that should > now find the closest: >   > > > myvscan<-data.frame(c(1,NA,1.5

Re: [R] Need a faster function to replace missing data

2009-05-22 Thread jim holtman
less than > the one of interest. In this case, the correct replacement should have been > 40, not 30, since 12:15 from mygarmin is closer to 12:14 in myvscan than > 12:10. Is there a way to get the function to find the closest in value > instead of the next smaller value? I was tryi

Re: [R] Need a faster function to replace missing data

2009-05-22 Thread Tim Clark
Aloha, Tim Tim Clark Department of Zoology University of Hawaii --- On Fri, 5/22/09, jim holtman wrote: > From: jim holtman > Subject: Re: [R] Need a faster function to replace missing data > To: "Tim Clark" > Cc: r-help@r-project.org > Date: Friday, May 22, 200

Re: [R] Need a faster function to replace missing data

2009-05-22 Thread jim holtman
I think this does what you want. It uses 'findInterval' to determine where a possible match is: > myvscan<-data.frame(c(1,NA,1.5),as.POSIXct(c("12:00:00","12:14:00","12:20:00"), format="%H:%M:%S")) > # convert to numeric > names(myvscan)<-c("Latitude","DateTime") > myvscan$tn <- as.numeric(myvsca

Re: [R] Need a faster function to replace missing data

2009-05-22 Thread William Dunlap
Here are 2 functions, which.just.above and which.just.below, which may help you. They will tell which element in a reference dataset is the first just above (or just below) each element in the main dataset (x). They return NA if there is no reference element above (or below) an element of x. The

Re: [R] Need a faster function to replace missing data

2009-05-22 Thread Dieter Menneq
Tim Clark yahoo.com> writes: > > I need some help in coming up with a function that will take two data sets, determine if a value is missing in > one, find a value in the second that was taken at about the same time, and substitute the second value in for > where the first should have been. T