Question: Submit the compiled file ( docx , pdf , or html ) . 1 . Your file must includes your codes for Question # 1
Submit the compiled file docx pdf or html
Your file must includes your codes for Question #
Each script should be commented by Question Number, such as #Question prior to each of the coding.
The script should be compiled successfully.
# Write a new function called MyVectorInfo that takes as input a vector and returns the key characteristics of vector, such as the min, the max, and the mean of the vector. Make sure to give careful thought about the parameters you will need to pass to your function and what kind of data object your function will return.
# HINT: If you are not sure how to start, use ALL the functions listed below there are other ways doing this:
functionmyVector;return;c; which.max; mean; which.min; MyVectorInfo; ;
myVector c
# define a new function "MyVectorInfo"
MyVectorInfo function
min vector
max vector
mean meanvector
cmin max, mean
MyVectorInfomyVector
#
Complete the script by populating the empty space to produce the output shown.Pay attention to the space holder vs actual call of an object. For the first two boxes, do not write in numbers. They should be an object name or a space holder name either y or p
Code:
y
newround functionp digits round digits
cnewround newroundy digits
Output:
#
Complete a function by replacing answer with a base R function you've learned this week that gives random numbers when throwing a fair die.
Hint : In side your function, you may want to use sample function to randomly select one number from a die. Hint : The outcome will be like this: since it is a random number, you will see different value in your scree.
throwdie
throwdie
throwdie
#Your function to complete.
throwdie function
number answer: size
number
#
Watch the assigned video, and practice the content. Then, write a function, named worstWithIndex that will print the name of the car that has the worst mpg This function will take column index as an input.
For example, when you successfully write the function and run the function using the first index like below, the result should be like this:
worstWithIndex
"Cadillac Fleetwood"
Write or complete your function by populating the yellow highlighted parts below:
worstWithIndex functioncolindex,
index Select whichmin", "max", "min", "which.max"mtcars Select col.index", "col.index,", "mtcars$mpg
rnames Select "colnames", "mtcars$mpg "rownames", col.index"mtcars #read the row names of mtcars object
car rnames Select mtcars "index", "index,
returncar
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
