非常感谢耐心指点,就是在构建这个表格时,第2段代码
Define format for fixed width file
cols <- data.frame(name = c("id", "year", "month", "element"), start = c(1, 12, 16,
18), end = c(11, 15, 17, 21))
names <- str_c(c("value", "mflag", "qflag", "sflag"), rep(1:31, each = 4), sep = "_")
starts <- cumsum(c(22, rep(c(5, 1, 1, 1), 31)))
starts <- starts[-length(starts)]
ends <- c(starts[-1], starts[length(starts)] + 1) - 1
values <- data.frame(name = names, start = starts, end = ends)
cols <- rbind(cols, values)
代码上下文片断