Skip to content

remNANs_spline() should not fail when rows have less than 80% of NANs #8

@inesphilippart98

Description

@inesphilippart98

The following code fails when rowSums(indNAN) is always <= N*0.8 because then nanLead is empty and therefore X[-nanLE,] contains no rows and t1 and t2 will be infinite and the function stats::spline() will fail.

Instead the code should work in all cases including when there is no rows full of NaNs.
I don't understand why there is this 80% threshold.

}else if(options$method == 2){ # replace missing values after removing leading and closing zeros
   
   rem1 <- (rowSums(indNaN)>N*0.8)
   nanLead <- which(rem1)
   # nanEnd <- which(rem1[length(rem1):1])
   # nanLE <- c(nanEnd,nanLead)
   nanLE<-nanLead
   X<-X[-nanLE,]
   indNaN=is.na(X)
   for (i in 1:N){  
     x = X[,i]
     isnanx = is.na(x)
     t1 = min(which(!isnanx))
     t2 = max(which(!isnanx))
     
     x1<-stats::spline(x[t1:t2],xout = 1:(t2-t1+1))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions