util.character: Functions to Manipulate Character Objects

Description Usage Arguments Details Value Examples

Description

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

Usage

1
2
3
  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

1
2
3
4
5
6
7
## 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=".")


Search within the CHNOSZ package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.