[R] for loop to list files
Jeff Newmiller
jdnewmil at dcn.davis.CA.us
Mon Apr 21 20:09:31 CEST 2014
You seem overly intent on getting a for loop into your code. Jorge's solution has the same effect as your for loop.
---------------------------------------------------------------------------
Jeff Newmiller The ..... ..... Go Live...
DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engineer (Solar/Batteries O.O#. #.O#. with
/Software/Embedded Controllers) .OO#. .OO#. rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.
On April 21, 2014 1:55:38 AM PDT, "Beatriz R. Gonzalez Dominguez" <aguitatierra at hotmail.com> wrote:
>Hi Jorge,
>
>Thanks so much! Exactly what I wanted. Finally I wrote:
>
>for(i in 1976:1981){
>PE.files_01_7681 <- paste("val_mapped_petpe_", 1976:i, "01.txt",
>sep="")
>}
>
>Cheers,
>Bea
>
>
>On 21/04/2014 10:46, Jorge I Velez wrote:
>> Hi Beatriz,
>>
>> Try
>>
>> paste("val_mapped_petpe_", 1976:1981, "01.txt", sep="")
>>
>> Best,
>> Jorge.-
>>
>>
>> On Mon, Apr 21, 2014 at 6:43 PM, Beatriz R. Gonzalez Dominguez
>> <aguitatierra at hotmail.com <mailto:aguitatierra at hotmail.com>> wrote:
>>
>> Dear all,
>>
>> I'm trying to create a loop to select a series of files into my
>> computer but I haven't been successful until now. I've looked
>into
>> different possibilities but none has worked. I'd appretiate if
>you
>> could help me by providing me with some ideas.
>>
>> Basically what I'd like to do is to create a character string
>> variable [1:5], same as the one that could be obtained with
>> 'list.files', but using a 'for' loop.
>>
>> This is one of the things I've tried but obviously doesn't yield
>> the results I would like:
>>
>> for(i in 1976:1981){
>> PE.files_01_7681 <- paste("val_mapped_petpe_", i, "01.txt",
>sep="")
>> paste(PE.files_01_7681[i])
>> }
>>
>> Many thanks!
>>
>> ______________________________________________
>> R-help at r-project.org <mailto:R-help at r-project.org> mailing list
>> 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 at r-project.org mailing list
>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.
More information about the R-help
mailing list