Home » R Programming Tutorial » R Data Types

# R Data Types

Datatypes are the format in which the data is stored as a variable. The variables are
assigned to R-objects and data type of the R-object becomes the data type of the variable.

## There are following R Objects

Vectors
Lists
Matrices
Arrays
Factors
DataFrames

These will be discussed in detail later.

## R – Data Types

### Numeric

```x <- c(5,3,7,8)
print(x)```

Output

` 5 3 7 8`
`print(class(x))`

Output

`##  "numeric"`

### Integer

```x <- c(5,3,7,8)
x <- as.integer(x)
print(x)```

Output

`##  5 3 7 8`
`print(class(x))`

Output

`##  "integer"`

### Complex

```x <- 4+7i
print(x)```

Output

`##  4+7i`
`print(class(x))`

Output

`##  "complex"`

### Character

```x <- 'myname'
print(x)```

Output

`##  "myname"`
`print(class(x))`

Output

`##  "character"`

### Logical

```x <- TRUE
print(x)
```

Output

`##  TRUE`
```print(class(x))
```

Output

`##  "logical"`

### Raw

```x <- charToRaw("Hello World")
print(x)
```

Output

`##  48 65 6c 6c 6f 20 57 6f 72 6c 64`
```print(class(x))
```

Output

`##  "raw"`
READ  Getting Started with R - Help in R
 Array Interview Questions Graph Interview Questions LinkedList Interview Questions String Interview Questions Tree Interview Questions