I think you want file.path(). you can use that to make a directory that includes a path to it. See ?file.path for more details. Then, you can do something like
mydir ,- file.path(whatever)1, whatever2). setwd(mydir) but mydir needs to exist before you do that so check existence first using file.exists(). On Wed, Mar 4, 2020 at 8:22 PM Jarrett Phillips <phillipsjarre...@gmail.com> wrote: > Hi All, > > I am updating my R package that is currently on CRAN. > > I am looking to have my main package function iterate through some files in > a directory, but am having some issues. In my function, I do the following > (I might switch to 'replicate()' instead since non-preallocated for loops > can be very slow): > > file.names <- dir(path, pattern = ".fas") > for (i in 1:length(file.names)) { > # read in DNA sequences using 'pegas' package > seqs <- read.dna(file = file.names[i], format = "fasta") > } > > However, I am uncertain how my function should handle the 'path' argument > to dir(). I could provide 'path' as an explicit argument to my function, > but is there a less direct way? > > What I'm after is something like 'file.choose()', except for a folder, > rather than a file. > > Has anyone implemented something similar in their R packages? > > Thanks! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-package-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-package-devel > [[alternative HTML version deleted]] ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel