Displaying 2 results from an estimated 2 matches for "ind_temp".
2012 May 10
1
stop calculation in a function
...ody tell me what I should modify or add in my function in order
to fix this problem?
Here's the function. Thanks for your advises!
out2NA <- function(x,seuil){
st1 = NULL
# Temporal variable memorysing the last "correct" numeric value#
temp <- st1[1] <- x[1]
ind_temp <- 1
# Max time gap between two comparisons #
ecart_temps <- 10
tps <- time(x)
for (i in 2:length(x)){
if((!is.na(x[i]))){
if((tps[i]-tps[ind_temp] < ecart_temps) & (abs(x[i]-temp) > seuil)){
#&(abs(x[i+1]-x[i])<1)){
st1[i] <- NA
}...
2012 Apr 03
3
filling small gaps of N/A
...in my
data, but not the big gaps (more than 5 N/A following each other).
For the moment, i'm trying to do it by working with the time gap between the
2 numeric values surrounding the N/A as following:
imputation <- function(x){
met = NULL
temp <- met[1] <- x[1]
ind_temp <- 1
tps <- time(x)
for (i in 2:(length(x)) ){
if((tps[i]-tps[ind_temp] > 1)&(tps[i]-tps[ind_temp] <=
4)&(is.na(x[i]))){
met[i] <- na.approx(x)
}
else {
temp <- met[i] <- x[i]
ind_temp <- i
}
}
return(met)...