foo: example function

View source: R/fun-foo.R

fooR Documentation

example function

Description

A simple function to demonstrate how functions work.

Usage

foo(
  x,
  case = c("lower", "upper", "sentence"),
  spacing = 0,
  add = NULL,
  ignore = stop("STOP THIS MADNESS!")
)

Arguments

x

character vector

case

case that x will be put in: "upper", "lower" or "sentence"; can be specified in full or by partial match, e.g. the just first letter

spacing

integer specifying character spacing in x

add

(optional) text added before each string

ignore

ignored argument

Details

This is a not so simple function that does a simple task: given a character string it can change its case and character spacing, as well as add some text in front of it.

Value

A character string composed of added text and x.

Purpose

The purpose of this function is to demonstrate how functions work.

foo has four arguments. The first has no default and the function will throw an error if it is not supplied. The second has three possible values that can be partially matched and the first one is the default. The third has a default but can be set to any value, possibly generating warnings. The fourth is optional and defaults to NULL. The fifth is not evaluated at all.

Examples

foo("bar", case = "sentence", spacing = 1)


olobiolo/Rdlazer documentation built on Aug. 6, 2022, 11:37 a.m.