[R] inserting relative path - purrr

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Thu Mar 31 03:13:50 CEST 2022


?file.path

-Bill

On Wed, Mar 30, 2022 at 3:46 PM Jeff Reichman <reichmanj using sbcglobal.net>
wrote:

> R-help
>
> Having to perform an iteration so I'm looking at the purr package.  The
> problem I had was the files (*.csv) are in a Data subdirectory so I used
> the
> paste0 function to concatenate the subdirectory's relative path and the
> file
> name from the files list. While this works just fine is there a better way
> of adding the files path?
>
> # Load purrr library
> library(purrr)
>
> # Use map to iterate
> all_files_purrr <- map(paste0("../Data/", files), read_csv)
>
> # Output size of list object
> length(all_files_purrr)
>
> Jeff
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]



More information about the R-help mailing list