Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Each problem in this assignment asks you to write your own R function. Follow the instructions given and submit the code for your function as

image text in transcribed

Each problem in this assignment asks you to write your own R function. Follow the instructions given and submit the code for your function as the answer to the problem. Also provide output showing that you tested your function and that it works properly. You will need to create data objects to use for testing, or you can use data sets that we have previously used in class. Copy and paste your code and output into this doc. You will also submit your R script file. Each problem here gets progressively harder. 1) Write a function that converts temperatures from Fahrenheit to Celsius. The input should be a temperature in degrees Fahrenheit, and the output should be the corresponding temperature in degrees Celsius. 2) Write a function that takes in a vector of values and returns the cumulative means (similar to the cumsum() command, which you are allowed to use in your function here). Hint: Experiment with vector addition, subtraction, division, etc before you start writing your function. 3) Write a function that takes in a vector of values and returns the mean of that vector along with the number of items that are larger than the mean. Make sure your function can handle missing values in the data set. The function should also print a message to the user if there are any NA values. Hint: Look at the functions that you wrote in class. You may be able to use parts of them for this problem. 4) Write a function that takes in a matrix and returns the result of a user specified action (options: mean, min, max, and standard deviation) for each row in the data set. For example, if the user specifies mean, the function should return a vector containing the mean for each row. Set one of the actions to be the default action. The function should still be able to handle missing values and should print a message if there are any NA values. The message should also specify which row the missing value is in. Hint: Start with the last challenge function that you wrote in class. This is more or less an expansion of that function. 5) Alter the function from #4 to allow the user to specify whether computations should be done on the rows or the columns. For example, if the user specifies max and column, then the function should return a vector containing the max value each column of the matrix. If there are any NA values, the message should still specify which row the missing value is in. Each problem in this assignment asks you to write your own R function. Follow the instructions given and submit the code for your function as the answer to the problem. Also provide output showing that you tested your function and that it works properly. You will need to create data objects to use for testing, or you can use data sets that we have previously used in class. Copy and paste your code and output into this doc. You will also submit your R script file. Each problem here gets progressively harder. 1) Write a function that converts temperatures from Fahrenheit to Celsius. The input should be a temperature in degrees Fahrenheit, and the output should be the corresponding temperature in degrees Celsius. 2) Write a function that takes in a vector of values and returns the cumulative means (similar to the cumsum() command, which you are allowed to use in your function here). Hint: Experiment with vector addition, subtraction, division, etc before you start writing your function. 3) Write a function that takes in a vector of values and returns the mean of that vector along with the number of items that are larger than the mean. Make sure your function can handle missing values in the data set. The function should also print a message to the user if there are any NA values. Hint: Look at the functions that you wrote in class. You may be able to use parts of them for this problem. 4) Write a function that takes in a matrix and returns the result of a user specified action (options: mean, min, max, and standard deviation) for each row in the data set. For example, if the user specifies mean, the function should return a vector containing the mean for each row. Set one of the actions to be the default action. The function should still be able to handle missing values and should print a message if there are any NA values. The message should also specify which row the missing value is in. Hint: Start with the last challenge function that you wrote in class. This is more or less an expansion of that function. 5) Alter the function from #4 to allow the user to specify whether computations should be done on the rows or the columns. For example, if the user specifies max and column, then the function should return a vector containing the max value each column of the matrix. If there are any NA values, the message should still specify which row the missing value is in

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

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions

Question

What should Sheila have done to avoid interviews like this one?

Answered: 1 week ago