character(length = 0) as.character(x, ...) is.character(x)
charactercreates a character vector of the specified length. The elements of the vector are all equal to
as.characterattempts to coerce its argument to character type; like
as.vectorit strips attributes including names. For lists and pairlists (including language objects such as calls) it deparses the elements individually, except that it extracts the first element of length-one character vectors.
FALSEdepending on whether its argument is of character type or not.
is.characterare generic: you can write methods to handle specific classes of objects, see InternalMethods. Further, for
as.characterthe default method calls
as.vector, so dispatch is first on methods for
as.characterand then for methods for
as.character represents real and complex numbers to 15 significant
digits (technically the compiler's setting of the ISO C constant
DBL_DIG, which will be 15 on machines supporting IEC60559
arithmetic according to the C99 standard). This ensures that all the
digits in the result will be reliable (and not the result of
representation error), but does mean that conversion to character and
back to numeric may change the number. If you want to convert numbers
to character with the maximum possible precision, use
scipenaffects the conversion of numbers.
strsplitfor character concatenation and splitting,
chartrfor character translation and casefolding (e.g., upper to lower case) and
grepetc for string matching and substitutions. Note that
help.search(keyword = "character")gives even more links.
form <- y ~ a + b + c as.character(form) ## length 3 deparse(form) ## like the input a0 <- 11/999 # has a repeating decimal representation (a1 <- as.character(a0)) format(a0, digits = 16) # shows one more digit a2 <- as.numeric(a1) a2 - a0 # normally around -1e-17 as.character(a2) # normally different from a1 print(c(a0, a2), digits = 16)
Run the code above in your browser using DataCamp Workspace