Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write R code(s) (which is R programming codes) to create a numeric vector with 3

ID: 3773784 • Letter: W

Question

Write R code(s) (which is R programming codes) 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

7. Using the matrix counts created in question 7, write R code(s) to
       a. retrieve the count for Bell on Wed.
       b. retrieve the counts for Coach
       c. retrieve the counts on Mon

8. 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

9. 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

10. Write R code(s) to:
       a. Create a matrix calledamatrix 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 calledbmatrix 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 andbmatrix.

Mon

Tue

Wed

Adam

1

2

3

Bell

4

5

6

Coach

7

8

9

Explanation / Answer

6. Write R code(s) to create the following matrix called counts

Ans:

>> counts <- matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,ncol=3)

> names(x) NULL

> names(x) <- col("Mon","Tue","Wed")

7. Using the matrix counts created in question 7, write R code(s) to
       a. retrieve the count for Bell on Wed.

  


       b. retrieve the counts for Coach


       c. retrieve the counts on Mon

8. 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

>> counts <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12),nrow=4,ncol=3)

> names(x) NULL

> names(x) <- col("Mon","Tue","Wed")

> names(x) <- row("Adam","Bell","Coach","Dell")

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

>> counts <- matrix(c(1,2,3,10,4,5,6,11,7,8,9,12),nrow=4,ncol=4)

> names(x) NULL

> names(x) <- col("Mon","Tue","Wed","Thur")

> names(x) <- row("Adam","Bell","Coach","Dell")

10. Write R code(s) to:
       a. Create a matrix calledamatrix that looks like the one below.

> a <- matrix(1:9,nrow=3)

b. Create a matrix calledbmatrix that looks like the one below.

>b<- matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,ncol=3) ;

c. Transpose amatrix.

> a<- matrix(1:9,nrow=3)

d. Calculate the inner multiplication of amatrix and bmatrix.

> a <- matrix(1:9,nrow=3)

>b<- matrix(c(1,2,3,4,5,6,7,8,9),nrow=3,ncol=3)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote