原始数据有2115行但是输出线性插值的结果只有2114行,无法与原始数据匹配
n<-螺纹钢_的副本[,c("南京螺纹钢(HRB400E,20mm)市场价","合肥螺纹钢(HRB400E,20mm)市场价","螺纹钢1月合约收盘价","螺纹钢主力合约收盘价")]
xianxingchazhi<-function(n){
library(zoo)
n_filled <- n # 创建一个新的变量来存储填补后的结果
# 对每列进行插值填补
for (col in names(n)) {
n_filled[,col]<- na.approx(n[, col])
}
n_filled <- round(n_filled) # 将结果转换为精确到个位数
library(writexl)
write_xlsx(n_filled, "C:/Users/河童秃秃/Desktop/file.xlsx")
}
xianxingchazhi(n)
请给我一个解决思路