Re: [R] about reading files in order

2017-06-30 Thread Jeff Newmiller
See http://en.wikipedia.org/wiki/Internet_troll
-- 
Sent from my phone. Please excuse my brevity.

On June 30, 2017 10:50:45 AM EDT, lily li  wrote:
>Who is this person and what did he/she mean?
>
>On Fri, Jun 30, 2017 at 1:48 AM, Kindell Young 
>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"  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@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.
>>
>>
>
>   [[alternative HTML version deleted]]
>
>__
>R-help@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.

__
R-help@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.


Re: [R] about reading files in order

2017-06-30 Thread lily li
Who is this person and what did he/she mean?

On Fri, Jun 30, 2017 at 1:48 AM, Kindell Young  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"  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@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.
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] about reading files in order

2017-06-29 Thread lily li
Thanks also.

On Thu, Jun 29, 2017 at 2:12 PM, Adams, Jean  wrote:

> Thanks for that answer.
> I was not aware of gtools::mixedsort
> 
> function.
>
> Jean
>
> On Thu, Jun 29, 2017 at 2:47 PM, Henrik Bengtsson <
> henrik.bengts...@gmail.com> wrote:
>
>> You can use:
>>
>> > files <- list.files(path = "folder01")
>> > files <- gtools::mixedsort(files)
>>
>> to order the files in a "human-friendly" order rather than
>> lexicographic order (which sort() provides).
>>
>> FYI 1; it's preferred to use file.path("folder01", list[i]) rather
>> than paste('folder01',lists[i],sep='/').
>>
>> FYI 2; if you use list.files(path = "folder01", full.names = TRUE),
>> you get the full paths rather name just the file names, i.e. you don't
>> have to use file.path().
>>
>> /Henrik
>>
>> On Thu, Jun 29, 2017 at 12:04 PM, lily li  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@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/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> __
>> R-help@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/posti
>> ng-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] about reading files in order

2017-06-29 Thread Adams, Jean
Thanks for that answer.
I was not aware of gtools::mixedsort

function.

Jean

On Thu, Jun 29, 2017 at 2:47 PM, Henrik Bengtsson <
henrik.bengts...@gmail.com> wrote:

> You can use:
>
> > files <- list.files(path = "folder01")
> > files <- gtools::mixedsort(files)
>
> to order the files in a "human-friendly" order rather than
> lexicographic order (which sort() provides).
>
> FYI 1; it's preferred to use file.path("folder01", list[i]) rather
> than paste('folder01',lists[i],sep='/').
>
> FYI 2; if you use list.files(path = "folder01", full.names = TRUE),
> you get the full paths rather name just the file names, i.e. you don't
> have to use file.path().
>
> /Henrik
>
> On Thu, Jun 29, 2017 at 12:04 PM, lily li  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@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.
>
> __
> R-help@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.
>
>

[[alternative HTML version deleted]]

__
R-help@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.


Re: [R] about reading files in order

2017-06-29 Thread Henrik Bengtsson
You can use:

> files <- list.files(path = "folder01")
> files <- gtools::mixedsort(files)

to order the files in a "human-friendly" order rather than
lexicographic order (which sort() provides).

FYI 1; it's preferred to use file.path("folder01", list[i]) rather
than paste('folder01',lists[i],sep='/').

FYI 2; if you use list.files(path = "folder01", full.names = TRUE),
you get the full paths rather name just the file names, i.e. you don't
have to use file.path().

/Henrik

On Thu, Jun 29, 2017 at 12:04 PM, lily li  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@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.

__
R-help@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.


[R] about reading files in order

2017-06-29 Thread lily li
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@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.