Question: #### 5 . Values in the vector 'rainfall' are in inches. You can calculate the rainfall in centimeters by dividing each value by 0 .

#### 5. Values in the vector 'rainfall' are in inches. You can calculate the rainfall in centimeters by dividing each value by 0.3937. Write a 'for' loop to iterate over each value in the rainfall vector and print the rainfall in centimeters
```{r}
for(i in 1:length(rainfall))
{rainfall_cm <- rainfall[i]/0.3937
print(rainfall_cm)}
```
#### 6. Use a 'for' loop and an 'if-else' condition to print the values only if the rainfall is greater than 50 centimerters.
```{r}
for (i in 1: length(rainfall)){
rainfall_cm <- rainfall[i]/0.3937
if (rainfall_cm >50)
print(rainfall_cm)
}
```
#### 7. Create a function to covert rainfall in inches to centimeters. Round the answer to 2 decimal places. Pass the value 24 to the function and print the output with "cm" at the end.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!