Ich mag mehrere Textdateien aus meinem Verzeichnis lesen, die Dateien in folgendem FormatFehler beim Lesen multple Textdateien aus dem Verzeichnis in R
regional_vol_GM_atlas1.txt
regional_vol_GM_atlas2.txt
........
regional_vol_GM_atlas152.txt
Daten aus den Dateien
667869 667869
580083 580083
316133 316133
3631 3631
sieht in folgendem Format angeordnet sind,
finden Sie das Skript, das i
library(readr)
library(stringr)
library(data.table)
array <- c()
for (file in dir(/media/dev/Daten/Task1/subject1/t1)) # path to the directory where .txt files are located
{
row4 <- read.table(file=list.files(pattern ="regional_vol*.txt"),
header = FALSE,
row.names = NULL,
skip = 3, # Skip the 1st 3 rows
nrows = 1, # Read only the next row after skipping the 1st 3 rows
sep = "\t") # change the separator if it is not "\t"
array <- cbind(array, row4)
}
ich anfallenden follo geschrieben Flügel Fehler
Error in file(file, "rt") : invalid 'description' argument
mich freundlich vorschlagen, wo ich im Drehbuch falsch war
'myfiles <- lapply (list.files (...), read.table (...))' ist ein besseres Muster – arvi1000
OP: Der Code effektiv mehrere Dateien '(list.files ist vorbei()) 'to' read.table' –
@RS die Werte von in row4 gespeichert sind, gibt es 900 Dateien, so erwarte ich 900 Werte, aber ich sehe nur 1 Wert – DevanDevak