about reading files in order
Who is this person and what did he/she mean?
On Fri, Jun 30, 2017 at 1:48 AM, Kindell Young <kyb22 at email.vccs.edu> wrote:
On Jun 29, Silly FAGGOTS DICKS [R] 4 chicks not 18-40 year old dudes with no life or reason too still live except wasting our worlds oxygen on pathetic excuses of nothings that should eat a bullet for their next meal instead of bull SHIT ( although I know they like the taste of shit) (its a favorite of ]r[ist subscribers ) Show quoted text 15:04, "lily li" <chocold12 at gmail.com> wrote:
Hi R users,
I have a question about opening the txt files and putting them into a
matrix. The txt files are in the folder01, while they have the name
file.1.txt, file.2.txt, file.3.txt, etc. There are about 200 such text
files. Each txt file contains one value inside. When I tried to use the
code below, I found that the txt files are not in order, from 1, 2, 3, to
200. Rather, they are in the order 1, 10, 100, 101, etc. How to change it
so that they are in order? Thanks for your help.
temp <- list.files('folder01',pattern="*.txt"
name.list <-lapply(paste('folder01',temp,sep='/'),read.table,head=F)
library(data.table)
files.matrix <-rbindlist(name.list)
Also, when use the code below, how to complete it so that the values of
the
files are stored in a matrix?
lists = list.files('folder01')
for (i in 1:length(lists)){
file <- read.table(paste('folder01',lists[i],sep='/'),head=F)
print(file)
}
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/
posting-guide.html
and provide commented, minimal, self-contained, reproducible code.