R读取许多文件并定义列类/格式

时间:2018-06-18 15:36:44

标签: r

我想从这些文件中读取特定列: https://syzygydeutschland-my.sharepoint.com/:f:/g/personal/florian_roeming_syzygy_de/EtbmqO423_9Kq6o8uv2alk8B2d0DMnsG9-HT9AFzYryXfA?e=KW9Nz0 (你只需要一个档案就可以了)

使用:

library(data.table)
library("grid")
library("gmp")
library(anytime)
library(readr)
library(progress)

mehrere Datein einspielen /导入许多文件

temp <- list.files(pattern="*\\.tsv$")      # \\ und $ sichern, dass nur die tsv files gewählt werden
temp

daten importieren /从16列导入数据

test_data_3 <- lapply(temp,function(x){
#pb$tick()     # progress bar
read.csv(file = x,
       sep ="\t",
       fill = TRUE,
       quote='', 
       header = FALSE,
       stringsAsFactors = FALSE,
       #colClasses = c("numeric","character","character","character","character","character","numeric","character","numeric","character","character","numeric","numeric","numeric","numeric","numeric")
)[ ,c(287, 288, 289, 290, 291, 292, 293, 304, 370, 661, 662, 812, 813,994, 995, 1002)]
}
)

我使用

后出错
colClasses = c("numeric","character","character","character","character","character","numeric","character","numeric","character","character","numeric","numeric","numeric","numeric","numeric")

enter image description here

请注意:&#39; de-DE,de; q = 0.8,en-US&#39;是第一栏的内容。但这不是一个感兴趣的专栏。如何定义列格式(列类)?我也试过

dec = ","

但它没有用

0 个答案:

没有答案