Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago

Question

What is gravity?

Answered: 1 week ago

Question

What is the Big Bang Theory?

Answered: 1 week ago