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
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
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
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
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
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
6 matches
Mail list logo