Question: 1. Write R code to convert a list lst into a single vector. lst

1. Write R code to convert a list lst into a single vector.

lst <- list(c(1,2,3),c(6,7,10))

2. write R code to create a list that contains three vectors (each vector of length 5) that satisfy the following:

a. each entry in first vector is random number between 0 and 10.

b. each entry in second vector is random number between 10 and 20.

c. each entry in third vector is random number between 20 and 30.

3. x <- list(y=1:10, t="Hello", f="TT", r=5:20)

write an R statement that will give the sum of all items of vector r of list x.

4. b <- list(a=1:10, c="Hello", d="AA"),

write an R expression that will give all elements, except the second element, of the first vector of list b. (the result should be a vector (1,3,4,5,6,7,8,9,10) )

5. write R code to create a matrix (3 rows and 4 columns) that looks like this:

10 -10 10 -10
10 -10 10 -10
10 -10 10 -10

6. write R code to create a matrix (10 rows and 3 columns) that satisfies the following:

  • each entry in column #1 is random number between 0 and 10
  • each entry in column #2 is random number between 10 and 20
  • each entry in column #3 is randoml number between 20 and 30

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!