Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

toSymbols

Atomic Symbols Converter


Description

Converts character strings or atomic numbers into atomic symbols.

Usage

toSymbols(x, ...)

## S3 method for class 'integer'
toSymbols(x, ...)

## S3 method for class 'numeric'
toSymbols(x, ...)

## S3 method for class 'character'
toSymbols(x, nletters = 3, ...)

Arguments

x

a vector to be converted into atomic symbols.

nletters

an integer used to truncate the character strings before convertion.

...

further arguments passed to or from other methods.

Details

Each elements of x are converted into atomic symbols.
When x is an integer (or numeric) vector, atomic number are search into the elements data set to find associated atomic symbols.
When x is a character vector, toSymbols first removes all leading and trailing white spaces and numbers. Then translates the first character of the character strings to uppercase and all the others to lowercase. Finally, the character strings are tested for matching with element symbols provided by the elements data set. NA are produced for no matching.

Value

a character vector containing atomic symbols

See Also

Examples

x <- c(1:10)
toSymbols(x)

x <- c("C  "," o","h1","1h","UU","SI0","cR")
toSymbols(x)

# 'nletters' can be used to truncate the character strings before convertion, if need
toSymbols("SIL", nletters=3) # return NA
toSymbols("SIL", nletters=2) # return "Si"
toSymbols("SIL", nletters=1) # return "S"

Rpdb

Read, Write, Visualize and Manipulate PDB Files

v2.3
GPL
Authors
Julien Idé
Initial release
2014-02-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.