I have numerous tab delimited .txtfiles named as "abcd001.txt, abcd002.txt".... stored in a directory. I was able to import them using the following code, (whereby default directory is sames as data files directory). Its three column, all numeric type data
filenames <- list.files(path=".",pattern="abcd+.*txt")
#list of data in R
names <-substr(filenames,1,6)
for(i in names){
filepath <- file.path(".",paste(i,".txt",sep=","))
assign(i, read.table(filepath,
colClasses=c("numeric"),
sep = "\t"))
}
The code itself hasnt returned any error. My doubt is How can I access data which is being loaded? How to access say the data of the file abcd011.txt which should be three column data
The commands:names[3] just returns the file number 000002 But no data.
The code here is similar to one here: Read multiple CSV files into separate data frames.