This help topic is for R version 2.9.0. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/utils/html/type.convert.html
type.convert {utils}R Documentation

Type Conversion on Character Variables

Description

Convert a character vector to logical, integer, numeric, complex or factor as appropriate.

Usage

type.convert(x, na.strings = "NA", as.is = FALSE, dec = ".")

Arguments

x

a character vector.

na.strings

a vector of strings which are to be interpreted as NA values. Blank fields are also considered to be missing values in logical, integer, numeric or complex vectors.

as.is

logical. See ‘Details’.

dec

the character to be assumed for decimal points.

Details

This is principally a helper function for read.table. Given a character vector, it attempts to convert it to logical, integer, numeric or complex, and failing that converts it to factor unless as.is = TRUE. The first type that can accept all the non-missing values is chosen.

Vectors which are entirely missing values are converted to logical, since NA is primarily logical.

Since this is a helper function, the caller should always pass an appropriate value of as.is.

Value

A vector of the selected class, or a factor.

See Also

read.table


[Package utils version 2.9.0 ]