Question

In: Statistics and Probability

PLEASE NUMBER EACH ANSWER Students will use advanced looping methods including replicate(), lapply(), sapply(), and apply(),...

PLEASE NUMBER EACH ANSWER

Students will use advanced looping methods including replicate(), lapply(), sapply(), and apply(), and access datasets provided with R packages in an R script.

  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.

Solutions

Expert Solution


Related Solutions

There are a number of commonly used research methods that apply to the study of Learning....
There are a number of commonly used research methods that apply to the study of Learning. Describe one method that you think is the most important. Explain how this method has been used to research key findings in the field of Learning Theory. Propose your own research question related to Learning and Behavior that you might be interested in researching. How would you use this method to study your own question? Discuss any ethical considerations relating to either animal or...
Risk managers use a number of methods for managing risk. For each of the following, what...
Risk managers use a number of methods for managing risk. For each of the following, what method for handling risk is used?Explain your answer. a. The decision not to carry earthquake insurance on a firm's manufacturing plant b. The installation of an automatic sprinkler system in a hotel. c. The decision not to produce a product that might result in a product liability lawsuit. d. Requiring retailers who sell the firm's product to sign an agreement releasing the firm from...
Please use any of the methods to prove whether each of the following arguments is valid...
Please use any of the methods to prove whether each of the following arguments is valid or invalid. For each problem, please identify the method that you have decided to employ and make sure to show your work. 1. It is obvious that nuclear energy is needed. Nuclear energy is needed if and only if solar energy cannot be harnessed. And it is also true both that solar energy can be harnessed only if funds to do so are available,...
Please use ONLY one Excel file to answer the below questions. ( including the formula using...
Please use ONLY one Excel file to answer the below questions. ( including the formula using for Excel) In 2011, when the Gallup organization polled investors, 34% rated gold the best long-term investment. In April of 2013 Gallup surveyed a random sample of U.S. adults. Respondents were asked to select the best long-term investment from a list of possibilities. Only 241 of the 1005 respondents chose gold as the best long-term investment. By contrast, only 91 chose bonds. Compute the...
Directions: Answer each question to the best of your ability. Please show all work (including the...
Directions: Answer each question to the best of your ability. Please show all work (including the 7 steps of Hypothesis Test) and round decimals to the nearest ten-thousandths. 3. A student organization uses the proceeds from a particular soft-drink dispensing machine to finance its activities. The price per can had been $0.50 for a long time, and the average daily revenue during that period had been $51.50. The price was recently increased to $0.60 per can. A random sample of...
Please only answer the first question! The OECD is a club of the most advanced economic...
Please only answer the first question! The OECD is a club of the most advanced economic nations in the world – based on living standards and per capita income more than absolute size. Newer members include Turkey, Mexico and Hungary. China and India are not yet members despite their vast populations. Currently the OECD has 32 members. The 2009 OECD Employment Outlook discusses prospects for unemployment and possible policy responses. The evolution of unemployment depends on (a) the size of...
PLEASE ANSWER ALL QUESTIONS. ALL THE QUESTION ARE RELATED IN EVERY NUMBER 1. "For each of...
PLEASE ANSWER ALL QUESTIONS. ALL THE QUESTION ARE RELATED IN EVERY NUMBER 1. "For each of the following questions, use a dry bulb temperature of +26°C and a wet bulb temperature of +15°C, in a room with 70 kg of dry air. The atmospheric pressure is 101,325 Pa. What is the relative humidity of this air? Enter your answer as a number from 0 to 100 without any units or percent sign. Your answer is correct if it is within...
What are three methods for valuing common stocks, and when does each apply?
What are three methods for valuing common stocks, and when does each apply?
including pictures , defining and explaining the use, extraction methods and the contribution of Aggregate mining...
including pictures , defining and explaining the use, extraction methods and the contribution of Aggregate mining to the Ontario economy(3 page minimum without diagrams) please type your answer, Please do not write on the paper and post it
Please answer all parts, thank you, and please type your answer and show all work including...
Please answer all parts, thank you, and please type your answer and show all work including excel formulas Exercise 15-15 The following data were taken from the balance sheet accounts of Shamrock Corporation on December 31, 2016. Current assets $554,000 Debt investments 596,000 Common stock (par value $10) 455,000 Paid-in capital in excess of par 148,000 Retained earnings 800,000 Prepare the required journal entries for the following unrelated items. (Credit account titles are automatically indented when amount is entered. Do...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT