Look at the collapse argument to the paste function. You should be able to do what you want much simpler without any explicit for loops.
-- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Matteo Mattiuzzi > Sent: Wednesday, October 28, 2009 11:28 AM > To: R-help@r-project.org > Subject: [R] output of "for" > > Hello! > > I've got troubles on following thing: > > As output I need a string like: > INPUT_FILENAMES = > H:\\AKK_temp\\Modis\\MOD13Q1\\austria\\MOD09Q1.A2008073.h18v04.005.2008 > 083134952.hdf|H:\\AKK_temp\\Modis\\MOD13Q1\\austria\\MOD09Q1.A2008073.h > 19v04.005.2008082182221.hdf > The filenames (dates) are with pathname (wrkdr) and separated with "|". > The number of input filenames changes (minimum 1, maximum n) > > wrkdr <- "H:\\akk_temp\\Modis\\MOD09" > dates is a data.frame where each row is a date and each column is a > Modis-image (the name of it) > > I did this as following: > paste('INPUT_FILENAMES = ', for(g in 1:(ntiles-1)) > {paste(wrkdr,'\\',dates[i,g+1],'|',sep='')} , for(g in ntiles){ > paste(wrkdr,'\\',dates[i,g+1],sep='') } ,sep='') > > ....and this did work (in an other "wrkdr" and other "dates") but after > changing, "for" gave no more output. And I don't know why!!! > > Why i use "for" twice? Because after the last file there is no "|"... > > > Thanks for help > > Matteo > > > > > > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.