fakeLines: Create fake text for testing purposes

View source: R/NCmisc.R

fakeLinesR Documentation

Create fake text for testing purposes

Description

Returns randomized input as if reading lines from a file, like 'readLines()' Can be used to test i/o functions, robustness.

Usage

fakeLines(
  max.lines = 10,
  max.chars = 100,
  pc.space = 0.35,
  delim = " ",
  can.null = TRUE
)

Arguments

max.lines

maxmimum number of fake lines to read

max.chars

maximum number of characters per line

pc.space

percentage of randomly generated characters that should be a delimiter

delim

what should the simulated delimiter be, e.g, a space, comma etc. If you wish not to include such either set the delimiter as "", or set pc.space=0.

can.null

whether with probability 1/max.lines to return NULL instead of any lines of text, which simulates an empty file, which for testing purposes you may want to be able to handle

Value

a vector of character entries up 'max.chars' long, or sometimes only NULL if can.null=TRUE

Author(s)

Nicholas Cooper

Examples

fakeLines() # should produce between zero and ten lines of random text, 35% of which are spaces

NCmisc documentation built on Oct. 17, 2022, 5:09 p.m.