Data types and structures

We have seen that R works with objects which are characterized by their name and their content. However, these objects have more attributes which specify the kind of data stored in that object.

In order to understand the usefulness of these attributes, consider a variable that takes the value 1, 2, or 3: such a variable could be an integer variable (for instance, the number of kids in a family), or the coding of a categorical variable (for instance, the gender of the respondent: male, female, other, did not declare).

R will not process these variables in the same way: with R, the attributes of the object give the necessary information for the functions to use the correct process.

All objects have two intrinsic attributes: mode and length.

The mode is the basic type of the elements of the object; there are four main modes:

  • numeric
  • character
  • logical (FALSE or TRUE).
  • complex

During this course, we will not work with complex numbers, so we haven’t included any information about this mode. Besides, other modes exist but they do not represent data, for instance function or expression, and we are not looking at these modes here.

In this section, you will learn more about

  1. What are the basic modes in R

  2. How to combine data into:

  1. How to import data you have stored in other formats, especially text or excel formats into such structures

You can work on the following tutorial for hands on exercises related to this section: Proceed to the tutorial


Image source