```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## R Space

&nbsp;

<center>

> You are floating in R Space, alone but for your data

```{r, echo=FALSE, out.width="60%", fig.cap=""}
knitr::include_graphics("img/r-space.png")
```

</center>

## What you will learn

&nbsp;

- Basic data types in R, str()
- Categorical data
- class() and converting variables
- Vector and matrix fun


## Basic data types in R, str()

&nbsp;

**Data objects** are storage containers

&nbsp;

```r
x <- 1 # single numeric integer

y <- c(4.43, 2.70) # vector of numeric decimal values

z <- c("Bob", "Karen") # vector of character strings
```

##  The Global environment "R space"

&nbsp;

<center>

```{r, echo=F, out.width="90%", fig.cap=""}
knitr::include_graphics("img/first-data.png")
```

</center>

##  The Global environment "R space"

&nbsp;

<center>

```{r, echo=F, out.width="75%", fig.cap=""}
knitr::include_graphics("img/1.3-global-env.png")
```

</center>

##  Variable name conventions

&nbsp;

- Can contain letters, numbers, some symbolic characters

- Must begin with a letter

- Must not contain spaces

- No forbidden characters like '+', '-', '@', and others

- Should be human-readable, consistent, and not too long

- Case sensitive


## Factors

&nbsp;

**A factor is data where the different values are categories**

- Ordered factor

`'Monday', 'Tuesday', 'Wednesday...'`

- Non-ordered factor

`"Staffordshire", "Lancashire"...`

&nbsp;

Generally need to think about this when analysing data

## `class()` and converting variables

&nbsp;

- The `class()` function can be use to see what R thinks your variable class is

- Also, the Global Environment

<center>

```{r, echo=FALSE, out.width="90%", fig.cap=""}
knitr::include_graphics("img/1.3-class.png")
```

</center>

## Vectors and matrices

&nbsp;

**Vector** 

- stores data in a single dimension from 1 to i, my_vec[i]

**Matrix** 

- stores data in two dimensions 1 to i rows, 1 to j columns my_mat[i, j]

**Array**

- 3 dimensions to i, j, and k my_array[i, j, k]

## Live coding

&nbsp;

<center>

```{r, echo=FALSE, out.width="60%", fig.cap=""}
knitr::include_graphics("img/cat-laptop.jfif")
```

</center>


