Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In your R script: a. (10 pts) Store following age category values in a factor named age: 26-50, 51-75, 51-75, 26-50, 0-25, 26-50, 0-25, 51-75,

In your R script: a. (10 pts) Store following age category values in a factor named age: 26-50, 51-75, 51-75, 26-50, 0-25, 26-50, 0-25, 51-75, 26-50, 0-25 Set the order of the levels as 0-25 < 26-50 < 51-75 and print the factor. Add one more value (75+) to your factor as the last element. Since it is not a defined level in the factor, you need to add the level first. Print the factor after adding the new value. b. (10 pts) Create a list named myList with the following four elements (with their names): 1. numbers: The even numbers from -30 to 30. 2. strings: Five character strings a,b,c,d,e. 3. matrix: One 2x3 matrix 5 3 1 8 4 6 . 4. logical: Two logical values TRUE and FALSE. Print the sum of the numbers. Change the value of the last element of the strings as k. Change the matrix with its transpose. Remove logical from the list. Print the list. c. (15 pts) Monday Tuesday Wednesday Thursday Friday Week1 325 337 465 192 332 Week2 199 389 513 312 298 Week3 244 399 336 217 287 Store the daily sales of a product (given above) for three weeks in a matrix object. Assign the row names and column names as given in the table above. Compute and print the average sales of each week (row) and average sales of each day (column). Insert the sales on the weekend to the matrix using cbind function. Saturday Sunday Week1 262 229 Week2 223 148 Week3 412 403 Print the sales of Week1 and Week3 on Tuesday, Thursday, and Saturday as a submatrix.

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

Database Design For Mere Mortals

Authors: Michael J Hernandez

4th Edition

978-0136788041

More Books

Students also viewed these Databases questions