Question: Please answer using Rstudio Put the numbers 1 to 6, 8 to 13, 12 to 17 in three vectors named v1, v2 and v3 (use

Please answer using Rstudio

Please answer using Rstudio Put the numbers 1 to 6, 8 to

Put the numbers 1 to 6, 8 to 13, 12 to 17 in three vectors named v1, v2 and v3 (use the function seq). (1) print (use function print) the second, third and forth elements in v3: (2) print the elements in v3 that are larger than 13 and less than 16 (using syntax x [x m], x is a vector): (3) print the elements in v3 that are larger than 15 or less or equal to than 13 (using syntax x[x m], x is a vector): (4) Use the function length to give the length of v1. (5) Combine v1 and v2 into one vector v4. Create a matrix named Q with 3 columns such that v1 is the first, column, v2 is the second column, v3 is the third column. (1) Use function dim to give the size of the matrix: (2) print the second row of the matrix: (3) Use rbind to create a matrix with 2 rows such that v1 is the first, row and v2 is the second row. Make a data frame called df with three columns (called A, B and C) containing respectively v1, v1 + v2 and v1 + v2 + v3. (1) Use ncol mid nrow to give the number of rows and columns of the data.frame. (2) Output the sum of each column by using colSums: (3) Output the average of each row by using rowMeans: (4) Without knowing that B is in the second column, how can you get the column b? (using $ or [[]]): (5) Rename the columns as a1, a2, a3 using colnames. (6) Try the command apply (df, 2, sum) and apply (df, 1, mean), what do you get? Use help to know the details of function apply

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!