Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The function call, rnorm(1), generates a normal random number. Use replicate() to generate 10 normal random numbers and assign them to a vector called nums

  1. The function call, rnorm(1), generates a normal random number. Use replicate() to generate 10 normal random numbers and assign them to a vector called nums.
  2. The R statement, data(iris), loads the built-in R data set iris. This dataset has 150 rows and 5 columns. The 5 column names are "Sepal.Length","Sepal.Width","Petal.Length","Petal.Width" and "Species".
    1. Write R code(s) to return a list of 4 items that correspond to the averages of the first 4 columns in iris. The contents of the list should be as follows: $Sepal.Length [1] 5.843333 $Sepal.Width [1] 3.057333 $Petal.Length [1] 3.758 $Petal.Width [1] 1.199333
  3. With the iris dataset still loaded,
    1. write R code(s) to return a vector of 4 items that correspond to the averages of the first 4 columns in iris. The contents of the vector should be as follows:

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

5.843333

3.057333

3.7580000

1.199333

  1. The following R code converts the contents of the first 4 columns in iris to a matrix called data. data=as.matrix(iris[,1:4])
    1. Write R code(s) to use apply() to return a vector that contains the max values of the 4 columns. The contents of the vector should be as follows [Hint, use max()]:

Sepal.Length

Sepal.Width

Petal.Length

Petal.Width

7.9

4.4

6.9

2.5

  1. Write R code(s) to read the contents of the provided file COS-206-ShoppingCart.html into a variable called cart and then show the first 5 lines of cart.

#5 provided below html

Table for Shopping Cart

Your Cart
Item Code Price Quantity Amount
Hand Shovel G01 4.99 1 4.99
Nice Saw H01 24.99 1 24.99
Subtotal: 29.98

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_2

Step: 3

blur-text-image_3

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 Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions