# a general function to return a vector of values with NAs where they belong # x is shortened data vector, vec.of.NA is boolean - Pete Hurd reinsert.na <- function(x,vec.of.NA){ data.out <- rep(NA,length(vec.of.NA)) cdi <- 1 # cdi=current data index for (i in 1:length(vec.of.NA)){ if(!vec.of.NA[i]){ data.out[i] <- x[cdi] cdi <- cdi+1 } } return(data.out) }