R - as function

Card Puncher Data Processing

Example

> x = 0:3
> class(x)
[1] "integer"
> as.logical(x)
[1] FALSE  TRUE  TRUE  TRUE
> as.character(x)
[1] "0" "1" "2" "3"
> as.numeric(x)
[1] 0 1 2 3
> as.complex(x)
[1] 0+0i 1+0i 2+0i 3+0i





Discover More
Card Puncher Data Processing
R - Coerce methods (Object Class conversion)

Type Coercion in R. The function as turns object into an object of class Class. In doing so, it applies a “coerce method”. The implicitly defined coerce methods may be overridden by a call to setAs....



Share this page:
Follow us:
Task Runner