[R] Append to file in loop

R. Michael Weylandt michael.weylandt at gmail.com
Sat Mar 24 16:10:32 CET 2012


for(i in 1:100){
   file.append(paste("file_", i, ".saam", sep = ""), "XFile.saam")
}

seems like it would work.

Michael

On Sat, Mar 24, 2012 at 10:42 AM, Luisin Galindo, PhD
<luisingalindophd at gmail.com> wrote:
> My files are on disk and they are regular text files named
>
> file_1 file_2 file_3 file_4 and file_5 with extension .saam
>
> The separator is sep='' (ie, white space)
>
> I want to append 'XFile' at the end of those files. XFile is also on disk.
>
> file.append("file_1.saam", "XFile.saam"); file.append("file_2.saam",
> "XFile.saam")...
>
> works but it would be tedious when I have 100 files to appendTo. Your help
> will be greatly appreciated.
>
> --
> Luisin Galindo, PhD
> Director, Departamento de Medicina Matematica
> Centro de Estudios Avansados en
>  Simulacion, Analysis, y Modelacion
> Puerto Castilla, Spanish Honduras
> Centro America
>
>        [[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