Movatterモバイル変換


[0]ホーム

URL:


rdrr.io

character: Character Vectors

characterR Documentation

Character Vectors

Description

Create or test for objects of type"character".

Usage

character(length = 0)as.character(x, ...)is.character(x)

Arguments

length

A non-negative integer specifying the desired length.Double values will be coerced to integer:supplying an argument of length other than one is an error.

x

object to be coerced or tested.

...

further arguments passed to or from other methods.

Details

as.character andis.character are generic: you canwrite methods to handle specific classes of objects,see InternalMethods. Further, foras.character thedefault method callsas.vector, so dispatch is first onmethods foras.character and then for methods foras.vector.

as.character represents real and complex numbers to 15 significantdigits (technically the compiler's setting of the ISO C constantDBL_DIG, which will be 15 on machines supporting IEC60559arithmetic according to the C99 standard). This ensures that all thedigits in the result will be reliable (and not the result ofrepresentation error), but does mean that conversion to character andback to numeric may change the number. If you want to convert numbersto character with the maximum possible precision, useformat.

Value

character creates a character vector of the specified length.The elements of the vector are all equal to"".

as.character attempts to coerce its argument to character type;likeas.vector it strips attributes including names.For lists and pairlists (including language objects such ascalls) it deparses the elements individually, except that it extractsthe first element of length-one character vectors.

is.character returnsTRUE orFALSE depending onwhether its argument is of character type or not.

Note

as.character breaks lines in language objects at 500characters, and inserts newlines. Prior to 2.15.0 lines weretruncated.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.

See Also

options: optionscipen affects the conversion ofnumbers.

paste,substr andstrsplitfor character concatenation and splitting,chartr for character translation and casefolding (e.g.,upper to lower case) andsub,grep etc forstring matching and substitutions. Note thathelp.search(keyword = "character") gives even more links.

deparse, which is normally preferable toas.character for language objects.

Quotes on how to specifycharacter / stringconstants, includingraw ones.

Examples

form <- y ~ a + b + cas.character(form)  ## length 3deparse(form)       ## like the inputa0 <- 11/999          # has a repeating decimal representation(a1 <- as.character(a0))format(a0, digits = 16) # shows one more digita2 <- as.numeric(a1)a2 - a0               # normally around -1e-17as.character(a2)      # normally different from a1print(c(a0, a2), digits = 16)

What can we improve?

R Package Documentation

Browse R Packages

We want your feedback!

Note that we can't provide technical support on individual packages. You should contact the package authors for that.

 
Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, readEmbedding Snippets.

Close

[8]ページ先頭

©2009-2026 Movatter.jp