File: read_all.Rd

package info (click to toggle)
r-cran-xfun 0.37%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 792 kB
  • sloc: ansic: 242; sh: 22; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/io.R
\name{read_all}
\alias{read_all}
\title{Read all text files and concatenate their content}
\usage{
read_all(files, before = function(f) NULL, after = function(f) NULL)
}
\arguments{
\item{files}{A vector of file paths.}

\item{before, after}{A function that takes one file path as the input and
returns values to be added before or after the content of the file.
Alternatively, they can be constant values to be added.}
}
\value{
A character vector.
}
\description{
Read files one by one, and optionally add text before/after the content. Then
combine all content into one character vector.
}
\examples{
# two files in this package
fs = system.file("scripts", c("call-fun.R", "child-pids.sh"), package = "xfun")
xfun::read_all(fs)

# add file paths before file content and an empty line after content
xfun::read_all(fs, before = function(f) paste("#-----", f, "-----"), after = "")

# add constants
xfun::read_all(fs, before = "/*", after = c("*/", ""))
}