Question: PLEASE LABEL EACH NUMBER and its ANSWER Write an R script that contains statements to accomplish the following numbered items. Use R comments (a line

PLEASE LABEL EACH NUMBER and its ANSWER

Write an R script that contains statements to accomplish the following numbered items. Use R comments (a line starting with the # symbol) to clearly indicate for which numbered item the statements are intended. A template file titled COS-206_Written_Assignment_Template.R can be found in the Course Documents folder.

  1. Create a factor vector called status, which has 4 levels, namely freshman, sophomore, junior, and senior.
  2. words=c(78.1,23.4,35.6,97.6).
    1. Write R code(s) to convert the vector words to a numeric vector called numbers, which contains the corresponding number for each item in words. For instance, the first item in numbersis 78.1.
  3. data=c(-1.7382021,1.0636014,1.9335294,0.4239470,-1.5176473,1.7202728,1.0427466,1.9482044,-0.7755854,0.4915089)
    1. What is the min, max, and mean of the vector data? (report at least 4 digits after decimal point).
  4. Write R code(s) to create the following sequence. 3.2,3.4,3.6,3.8,4.0,4.2,4.4,4.6,4.8
  5. Write R code(s) to create a numeric vector with 3 items 1, 2, and 3. The first item 1 has name one, the second item has name two, the third item has name three.
  6. Write R code(s) to create the following matrix called counts.

Mon

Tue

Wed

Adam

1

2

3

Bell

4

5

6

Coach

7

8

9

  1. Using the matrix counts created in question 7, write R code(s) to:
    1. retrieve the count for Bell on Wed.
    2. retrieve the counts for Coach
    3. retrieve the counts on Mon
  2. Write codes to add another row of data to the matrix counts created in question 7. The final matrix should looks like the one below.

Mon

Tue

Wed

Adam

1

2

3

Bell

4

5

6

Coach

7

8

9

Dell

10

11

12

  1. Write codes to add another column of data to the matrix counts created in question 7. The final matrix looks like below.

Mon

Tue

Wed

Thur

Adam

1

2

3

10

Bell

4

5

6

11

Coach

7

8

9

12

  1. Write R code(s) to:

a. Create a matrix called amatrix that looks like the one below.

[,1]

[,2]

[,3]

[1,]

1

4

7

[2,]

2

5

8

[3,]

3

6

9

b. Create a matrix called bmatrix that looks like the one below.

[,1]

[,2]

[,3]

[1,]

1

2

3

[2,]

4

5

6

[3,]

7

8

9

c. Transpose amatrix.

d. Calculate the inner multiplication of amatrix and bmatrix.

e. Find the inverse of the element-wise products of amatrix and bmatrix.

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!