StatsNotebook

Variable types in R and StatsNotebook

20 Sep, 2020 | 2 minutes read

Tags: Data Management, R Code


Follow our Facebook page or our developer’s Twitter for more tutorials and future updates.

The tutorial is based on R and StatsNotebook, a graphical interface for R.

There are four major variable types in StatsNotebook: Categorical, Numeric, Date and Character. By default, when data is loaded into StatsNotebook, the variables are either Numeric or Character variables.

Categorical variables are variables that have two or more categories. For example, sex is a categorical variable that we can code into male and female. Another exapmle is color, which we can code into Yellow, Red, Orange, etc. For many analyses, we will also need to specify the reference category

In R, we will need to specify categorical variables as factor variables.

Numeric variables are variables that measured in number. Examples are height and weight.

Date is a variation of numeric variable that is used for Time Series analysis.

Chracter variables contain character string. Address and Name are examples of character variable. These variables contains textual information and are not normally used for statistical analysis. By default, Categorical variable such as Sex (Male/ Female) will be coded as Character variable and we will need to convert them into Categorical variable manually.

To change the type of a variable, we can

  1. Click Data on the top
  2. Click the orange icon next to a variable’s name.
  3. Select the variable type that we need.

Variable Type Conversion

currentDataset$Sex <- factor(currentDataset$Sex, exclude = c("", NA))

Follow our Facebook page or our developer’s Twitter for more tutorials and future updates.