Re: [R] loop with files

From: Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk_at_idi.ntnu.no>
Date: Tue, 24 Jun 2008 12:37:44 +0200

Alfredo Alessandrini wrote:
>> can you *explain* what the goal is?
>>
>
> I want import any rwl files (cimfasy.rwl, rocquce.rwl, .......), in a
> data.frame with the name like to name of file rwl:
>
> cimfasy.rwl -> cimfasy
>
> rocquce.rwl -> rocquce
>
> with this loop:
>
>
>> library(dplR)
>>
>> files <- system("ls *.rwl", intern=TRUE)
>>
>> files
>>
> [1] "cimfasy.rwl" "rocquce.rwl"
>
>> for (i in files) {a <- read.rwl(i,header=0)}
>>

for (file in files)

    assign(gsub("\\.rwl$", "", file), read.rwl(file, header=0))

?assign
?gsub

vQ



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. Received on Tue 24 Jun 2008 - 10:40:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 24 Jun 2008 - 11:30:49 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive