我想将所有文件绑定在一起,我已经将此代码用于其他文件,并且运行良好,现在我遇到了整数和字符问题。 这是代码:
library(tidyverse)
library(dplyr)
read_pvt_file2 <- function(filename){
print(filename)
subject_id <- substr(basename(filename), 1, 8)
data <- read_csv(filename)
colnames(data) <- c("Nb", "RawTime", "reSYS", "reDIA", "Physiocal",
"Time", "Score")
data$Subject <- subject_id
data
}
all_csv_files_in_dir <- function(dir){
list.files(dir, pattern = "\\.csv$", full.names = TRUE, recursive = TRUE)
}
df_all <- bind_rows(map(all_csv_files_in_dir("F:/Study/Dawn simulation
light/Analysis/Hemodynamics/Labview Done BP files"), read_pvt_file2))
但这是我得到的错误:
Error in bind_rows_(x, .id) :
Column `Score` can't be converted from integer to character
您知道如何处理此错误吗? 谢谢。