~ Data Types & Data Structures


Data Types


Data values are stored in different ways depending on the data type--whether the values are numbers or text.

Although we do not often encounter the details of the memory representation, except when we need a rough estimate of how much RAM a data set might require, it is important to keep in mind what sort of data type we are working with because the computer code that we write will produce different results for different data types. For example, we can only calculate an average if we are dealing with values that have been stored as numbers, not if the values have been stored as text.

Another important issue is how collections of values are stored in memory. The tasks that we will consider will typically involve working with an entire data set, or an entire variable from a data set, rather than just a single value, so we need to have a way to represent several related values in memory.

Every individual data value has a data type that tells us what sort of value it is. The most common data types are numbers, which R calls numeric values, and text, which R calls character values.

Primitive Types

Boolean, true or false
Character
Floating-point, single-precision real number values
Double, a wider floating-point size
Integer, integral or fixed-precision values
Enumerated type, a small set of uniquely-named values

Composite Types

Array
Open Array
Record *or tuple
Union
Tagged union (or also called a variant)

Abstract Data Types

Container
List
Associative Array
Multimap
Set
Multiset
Stack
Queue
Double-ended Queue
Priority Queue
Tree
Graph