### write an r script that contains statements to address the following numbered items u 5189682

Write an R script that contains statements to address the following numbered items. Use R comments (a line starting with the # symbol) to clearly indicate for which item the statements are intended.

Considering a Character vector called

* statusDesc*=c(“senior”,”sophomore”,”junior”,”freshman”).

Write R code(s) to create a factor called * statusFac* that will take

*as an argument and has four levels in the order of “freshman,” ”sophomore,” ”junior,” and “senior.”*

**statusDesc**Use the following codes to generate 10 random numbers to represent 10 random ages.

set.seed(1)

* ages*=rnorm(10,24,24)

Based on the variable * ages*, use cut() to create a factor called ageFac that has 4 levels “child”,”teen”,”adult”, and “senior”.

The corresponding age ranges are (3,13],(13,18],(18,60],and (60,120]. For example, one must be older than 3 and not older than 13 to be called a child. The contents of * ageFac* should be as follows:

[1] child adult child senior adult child adult

[8] adult adult teen

Levels: child teen adult senior

Assuming a variable called * num* contains an integer,

write an if-else statement to display the message “it is an even number” if * num* is even, or “it is an odd number” if

*is odd.*

**num** (*Hint:* use %% 2 to check the remainder of * num* divided by 2).

Consider two variables, * score* and

*. The variable score contains a numeric value.Write an if-else if statement to:*

**grade**assign “A” to grade if score is greater than or equal to 90;

assign “B” to grade if score is greater than or equal to 80 but less than 90; or

assign “C” to grade if score is greater than or equal to 70 but less than 80.

Considering the following R codes

* a*=c(2,-4,-3,7,6)

*=1:5*

**b***=6:10*

**c**There is a numeric vector

*.*

**d**Assign the item in * b* to

*if the corresponding item in*

**d***is greater than 0, otherwise, assign the item in*

**a***to*

**c***. For instance, the first item in*

**d***is 2, which is greater than 0, therefore the first item of*

**a***should be 1, which comes from*

**d***.*

**b** (*Hint:* use if-else statement).

Write a repeat loop to print out the message “Hello World!” 10 times.

Write a while loop to calculate 9! (factorial).

Considering a vector * data*=seq(0,100,2), which represents all the even numbers from 0 through 100,

write a “for loop” to sum up all the items in * data*.