Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions