I'm trying to read in a bunch of .tsv files from a folder ('Test'), and I got this far:
files <- list.files("Test", pattern="*.tsv", full.names=TRUE)
for (i in 1:length(files)) assign(files[i], read.delim(files[i], na.strings = c(
"FAILED", "ERROR"))
)
This works, however the data frames it creates includes the file path and extension (in this case Test/ and .tsv resulting in a data frame named Test/100_1.tsv). I've been playing around with the code for a few hours trying to get it to name each data frame by the necessary information only (e.g., 100_1). If anyone has any suggestions, this novice would greatly appreciate the help.
fnames <- sub(".*(?<=\\/)(.*)(?=\\.tsv).*", "\\1", files, perl=T)