filesstrings (version 0.3.2)

PasteDifferentLengths: Paste vectors/files with different lengths/numbers of lines.

Description

Paste character vectors of different lengths, optionally inputting the vectors as file names, which become character vectors via readLines. Vectors are first extended to all be the same length via ExtendCharVec() and are then pasted together, with no separator put in when pasting empty strings. See the examples if you don't understand.

Usage

PasteDifferentLengths(files, sep = "")

Arguments

files
A character vector of files to be read in via readLines to be pasted. If you would like to use this function on vectors already in the environment (without reading in files), pass them into this argument as a list (see the examples).
sep
What (if anything) do you want to paste in between things as you're pasting them together.

Value

A character vector.

Examples

Run this code
PasteDifferentLengths(list(1:3, 1:4))
PasteDifferentLengths(list(1:3, 1:4), sep = "sSs")
writeLines(as.character(1:3), "PasteDifferentLengths1.txt")
writeLines(as.character(1:4), "PasteDifferentLengths2.txt")
PasteDifferentLengths(list.files(pattern = "PasteDifferentLengths"),
sep = "sSsepPp")
# clean up working directory
file.remove(list.files(pattern = "PasteDifferentLengths"))

Run the code above in your browser using DataLab