parseCharInput: Parse a comma seperated string

View source: R/parseCharInput.R

parseCharInputR Documentation

Parse a comma seperated string

Description

The "parseCharInput" function converts a comma-seperated string into a vector by splitting the string along the commas. If "convertToNumeric" is true, the elements of the string will be converted into numbers and a numeric vector will be returned.

Usage

parseCharInput(
  input,
  convertToNumeric = TRUE,
  sort = FALSE,
  expected,
  msg = "wrong length",
  checkdup = FALSE,
  missingMsg = "Unknown",
  checkProb = FALSE,
  valid = FALSE
)

Arguments

input

(Required) The string to be processed

convertToNumeric

(Optional) A logical value. Should the input should be converted into numerics? TRUE by default

sort

(Optional) A logical value. Should the resulting vector be sorted. FALSE by default

expected

(Optional) The expected length of the output vector. No check is performed by default

msg

(Optional) Error message to print if the input is not of the correct length specified by "expected". Default is "Wrong length"

checkdup

(Optional) A logical value. Should an error be generated if there are any duplicated value? FALSE by default

missingMsg

(Optional) Error message to print if the input is missing. Default is "Unknown"

checkProb

(Optional) A logical value. Should the function check that the output vector sums to one? FALSE by default

valid

(Optional) A logical value. Should the validNames function be used to check the validity of the extracted names? FALSE by default

Value

A numeric vector or a character vector depending on the convertToNumeric flag.

Author(s)

Romain Francois

See Also

parseHashString uses parseCharInput sequentially.

Examples


  

  ## Not run: 
  parseCharInput( "1,2,4")
  parseCharInput( "1,6,4", sort = TRUE )
  ## see also the unit tests for more examples
  file.show( system.file( "Runit", "runit.supportfunctions.R" ,
    package = "MSToolkit"))
  
## End(Not run)

MikeKSmith/MSToolkit documentation built on Feb. 15, 2024, 5:32 p.m.