util.character {CHNOSZ}R Documentation

Functions to Manipulate Character Objects

Description

Convert between strings and character objects. Test for ability to become numeric.

Usage

  c2s(x, sep = " ")
  s2c(x, sep = NULL, keep.sep = TRUE)
  can.be.numeric(x)

Arguments

x character object to convert (s2c, c2s, axis.label), or object to be tested (can.be.numeric).
sep character, the separator to insert or separator(s) to match (c2s, s2c).
keep.sep logical, retain the separator in the output (TRUE) or discard it (FALSE) (s2c).

Details

c2s joins the elements of a character object into a character object of length 1 (a string), and s2c splits a string into elements of a character object of length n+1, where n stands for the number of separators in the string. sep gives the separator to insert between successive items (in c2s) or the separator(s) to find in a string (in s2c). The default value of sep is a space (" ") in c2s. The default value for sep is NULL in s2c, indicating a separator at every position of x (the result in this case has length equal to nchar(x)). Argument keep.sep if TRUE (the default) instructs s2c to keep the separating values in the output. The maximum length of the object returned by s2c is determined by n; the default value of NULL indicates an unrestricted length.

can.be.numeric returns a value of TRUE or FALSE for each element of x.

Value

s2c, c2s and axis.label return character values. can.be.numeric returns logical.

Examples

  
  ## string to character
  s2c("hello world")
  s2c("hello world",sep=" ",keep.sep=FALSE)
  s2c("3.141592",sep=c(".","9"))
  # character to string
  c2s(aminoacids())
  c2s(aminoacids(),sep=".")

[Package CHNOSZ version 0.9-7 Index]