Learn R Programming

NCmisc (version 1.2.0)

fakeLines: 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
)

Value

a vector of character entries up 'max.chars' long, or sometimes only NULL if 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

Author

Nicholas Cooper

Examples

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

Run the code above in your browser using DataLab