首页 > 解决方案 > R read many files and define column class / format

问题描述

I want to read specific columns from this files: https://syzygydeutschland-my.sharepoint.com/:f:/g/personal/florian_roeming_syzygy_de/EtbmqO423_9Kq6o8uv2alk8B2d0DMnsG9-HT9AFzYryXfA?e=KW9Nz0 (it would be appropriate for you to take just one file)

with:

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

mehrere Datein einspielen/ import many files

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

daten importieren / import data from 16 columns

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)]
}
)

I get an error since I use

colClasses = c("numeric","character","character","character","character","character","numeric","character","numeric","character","character","numeric","numeric","numeric","numeric","numeric")

enter image description here

Please notice: 'de-DE,de;q=0.8,en-US' is the content of first column. But this is not a column of interest. how can I define the column-format (column-class)? I also tried

dec = ","

but it didnt work

标签: r

解决方案


推荐阅读