Social Media Research

02 R Data Analysis


Question

What means "coercion" in R and what are the rules?


Answer

Converting objects from one class to another is called coercion.

Rules:

numeric+character= character

xx<-c(1,"hi")

logical+character= character

yy<-c(TRUE, "hi")

numeric+logical=numeric

zz<-c(1, TRUE)




Comments

The ordering is roughly logical < integer < numeric < complex < character < list


coercion