如何重命名具有“X 或 X.1 或 X.3”值的列标题,但它应该使用下一列的标题引用和重命名。
代码:
library(pdftools)
library(data.table)
library(tabulizer)
pdf_file <- "new.pdf"
out2 <- extract_tables(pdf_file, pages =c(89), output = "data.frame")
out2<-as.data.table(out2)
colnames(out2)
实际输出:
"G" "X" "Day.7" "X.1" "Day.8" "X.2" "Day.9" "X.3"
预期输出:
"G" "Day.7 "Day.7" "Day.8" "Day.8" "Day.9" "Day.9"