Description Usage Arguments Details Value Author(s) References See Also Examples
In some sense, numeric and character are the most general
data types. as.best
converts to one of these, handling
missing or near-missing values systematically.
1 2 3 4 5 6 7 |
x |
object to be coerced |
prefix |
scalar character value to affix to numeric-like values in a vector containing non-numeric values |
na.strings |
character vector of values to treat as NA |
... |
ignored |
Data printed at the command prompt can contain many ambiguities. Factors
look just like character vectors. Empty strings look just like spaces. Leading
or trailing white space can be confused with alignment adjustments. The string value
'NA' can be confused with NA. Character 'TRUE' looks like logical TRUE
.
as.best.default
coerces its argument to character, strips leading and
trailing white space, and coerces na.strings
to NA. A numeric vector is returned
if all non-missing values can be coerced to numeric. A character vector is returned
if any non-missing values cannot be coerced to numeric. If a prefix is supplied (the default)
numbers in a mixed vector are prefixed thus; if prefix
is length zero, mixed
character-numeric gives an error.
The method for data.frame
coerces each column in turn, returning either
the updated data frame or an error indicating the first problematic column.
an object like x
Tim Bergsma
http://metrumrg.googlecode.com
as.character
as.numeric
as.mDate
as.comment
1 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.