- test <- data.frame(X1=c(TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE,FALSE,FALSE),
- X2=c(001, NA, NA, 002, NA, 003, NA, NA, NA))
- #step1
- index <- which(!is.na(test[,2]))
- #step2
- delta <- diff(c(index,length(test$X2)+1))
- #final step
- result <- rep(test[,2][index],delta)
- test3<- cbind.data.frame(test$X1, result)
- write.csv(test3,file = "result.csv")


雷达卡
京公网安备 11010802022788号







