**continuous or numeric**

If the variable can have number values (with or without decimals, may include negative numbers), it is said to be continuous or numeric. One can check if a variable is numeric using command:

**code:**

> xx = c(1,2,3,4,3,2,4,1,3)

> is.numeric(xx)

**output:**

TRUE

**code:**

> is.numeric(bwdf$age)

**output: **

[1] TRUE

**categorical or factor**

The variable is said to be factor or categorical if it has some separate levels, which are independent of each other. For example, cities variable may have A, B and C values. One can check if a variable is numeric using command:

**code:**

> xx = c('A','C','B','D','A','B','C','D')

> xx = as.factor(xx)

> is.factor(xx)

**output: **

TRUE

**code:**

> str(xx)

**output: **

Factor w/ 4 levels "A","B","C","D": 1 2 3 4

**code:**

> is.factor(bwdf$race)

**output: **

[1] TRUE

**code:**

> str(bwdf$race)

**output: **

Factor w/ 3 levels "1","2","3": 2 3 1 1 1 3 1 3 1 1 …

**ordered or ordinal**

The variable is said to be ordinal or ordered if it has some categories that are related to each other. Likert scale is commonly used in medical research and is an example of this. One can check if a variable is numeric using command:

**code:**

> xx = c('A','C','B','D','A','B','C','D')

> xx = as.ordered(xx)

> is.ordered(xx)

**output: **

TRUE

**code:**

> str(xx)

**output: **

Ord.factor w/ 4 levels "A"<"B"<"C"<"D": 1 2 3 4

***********************