Define the following vectors, which represent the weight and height of people on a particular team (in inches and pounds):

```
height <- c(59,60,61,58,67,72,70)
weight <- c(150,140,180,220,160,140,130)
#Define a variable:
a <- 150
```

Now that you have some data – explore

### Step 1: Calculating means

```
#1) Compute, using R, the average height (called mean in R)
mean(height)
```

`## [1] 63.85714`

```
#2) Compute, using R, the average weight (called mean in R)
mean(weight)
```

`## [1] 160`

```
#3) Calculate the length of the vector "height" and "weight"
length(height)
```

`## [1] 7`

`length(weight)`

`## [1] 7`

```
#4) Calculate the sum of the heights
sum(height)
```

`## [1] 447`

```
#5) Compute the average of both height and weight, by dividing the sum (of the height or the width, as appropriate), by the length of the vector. How does this compare to the ‘mean’ function?
sum(height)/length(height)
```

`## [1] 63.85714`

`sum(weight)/length(weight)`

`## [1] 160`

### Step 2: Using max/min functions

```
#6) Compute the max height, store the result in ‘maxH’
maxHeight <- max(height)
#7) Compute the min weight, store the results in ‘minW’
minWeight <- min(weight)
```

### Step 3: Vector Math

```
#8) Create a new vector, which is the weight + 5 (every person gained 5 pounds)
newWeight <- weight + 5
#9) Compute the weight/height for each person, using the new weight just created
newWeight/height
```

`## [1] 2.627119 2.416667 3.032787 3.879310 2.462687 2.013889 1.928571`

### Step 4: Using Conditional if statements

Hint: In R, one can do: if ( 100 < 150 ) “100 is less than 150” else “100 is greater than 150”

```
#10) Write the R code to test if max height is greater than 60 (output “yes” or “no”)
if(maxHeight > 60) "yes" else "no"
```

`## [1] "yes"`

```
#11) Write the R code to if min weight is greater than the variable ‘a’ (output “yes” or “no”)
ifelse(minWeight > a,"yes","no")
```

`## [1] "no"`