рдореБрдЦреНрдп рд╕рд╛рдордЧреНрд░реА рдкрд░ рдЬрд╛рдПрдБ

Data Type Conversion in R

Type conversions in R work as you would expect. For example, adding a character string to a numeric vector converts all the elements in the vector to character.

Use is. foo to test for data type foo. Returns TRUE or FALSEUse as. foo to explicitly convert it.

is.numeric(), is.character(), is.vector(), is.matrix(), is.data.frame()as.numeric(), as.character(), as.vector(), as.matrix(), as.data.frame)

Examples

┬а┬а┬а┬а
┬аto one long vectorto matrixto data frame
from vectorc(x,y)cbind(x,y)data.frame(x,y)
from vectorc(x,y)bind(x,y)data.frame(x,y)
from matrixas.vector(mymatrix)┬аas.data.frame(mymatrix)
from data frame┬аas.matrix(myframe)┬а

Dates

You can convert dates to and from character or numeric data. See date valuesfor more information.

To Practice

To explore data types in R, try this free interactive introduction to R course.