Question

Need help with this in R studio! A screenshot of how to do it would be...

Need help with this in R studio! A screenshot of how to do it would be helpful.

Create a function called "printVecInfo" that take a vector as input. To receive a full credit, when you test your function using this input:

printVecInfo(c(1,2,3,4,5,6,7,8,9,10,50))

The output should be:

mean: 9.545455
median: 6
min: 1 max 50
sd: 13.72125

****HINT: you can improvise this input inside of your function:

cat("mean:", mean(vector), "\n")

0 0
Add a comment Improve this question Transcribed image text
Answer #1

please find below the code screenchot, code, and output:

# printVecInfo.r

# printVecInfo.r

# function which takes the vector as argument
printVecInfo <- function(vector){
#using the all inbuilt function calculating result
cat("mean:", mean(vector), "\n")
cat("median:", median(vector), "\n")
cat("min:", min(vector), "\n")
cat("max:", max(vector), "\n")
cat("sd:", sd(vector), "\n")
}
# calling the function
printVecInfo(c(1,2,3,4,5,6,7,8,9,10,50))

# output

Please do let me know if u have any concern..

Add a comment
Know the answer?
Add Answer to:
Need help with this in R studio! A screenshot of how to do it would be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment: USING PYTHON Expected submission: TWO (2) Python files, main.py and HelperClasses.py Make a file called...

    Assignment: USING PYTHON Expected submission: TWO (2) Python files, main.py and HelperClasses.py Make a file called HelperClasses and create a class inside it called Helpers Inside Helpers, create 8 static methods as follows: 1.) Max, Min, Standard_Deviation, Mean a.) Each of these should take a list as a parameter and return the calculated value 2.) Bubble a.) This should take a list as a parameter and return the sorted list 3.) Median a.) This should take a list as a...

  • 3. Write a function called sort3 that takes a 3-element vector as its sole arguments. It uses if-statements, possibly nested, to return the three elements of the vector as three scalar output-argumen...

    3. Write a function called sort3 that takes a 3-element vector as its sole arguments. It uses if-statements, possibly nested, to return the three elements of the vector as three scalar output-arguments in nondecreasino-roer , i.e., the first output argument equals the smallest element of the input vector and the last output argument equals the largest element. NOTE: Your function may NOT use any built-in functions, e.g., sort, min, max, median, etc. (5 points) (bonus question). Write a function called...

  • Can you give me the code for Question 12 through using R-programming? The Question instruction is...

    Can you give me the code for Question 12 through using R-programming? The Question instruction is Above question 9. Please help. Functional programming For problems 9-12, you are shown a for loop. Write a function f which can be used with the indicated functional programming construct to "replace" this for loop. For example, if you are given: n - length(input) output vector("double", n) for (i in 1:n) { output I[i-(input[i mean(input[i]))/sd( input[[i]]) # replace with: output <-map(iput, f) then a...

  • What would the function look like in MATLAB? Write a function called mysort that takes a...

    What would the function look like in MATLAB? Write a function called mysort that takes a 3-element vector as its sole arguments. It uses if statements, possibly nested, to return a 3-element vector with its elements in non-decreasing order, i.e., the first element in the returned vector equals the smallest element of the input vector and the last element equals the largest element in the input vector. NOTE: Your function should not use any built-in functions, e.g., sort, min, max,...

  • Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the...

    Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...

  • Using c++ , screenshot of display output as well. Preferably using visual studio. The output is...

    Using c++ , screenshot of display output as well. Preferably using visual studio. The output is Random I believe doesn’t have to be the same, Attached is the input a & b txt file as well. Question -1: input_a.txt is provided on Blackboard to populate the linked list. Write a function in C++ program that will take the head of the linked list and remove the duplicate values from the list. Perform operations on a singly linked list. CAWINDOWSlsystem321cmd.exe Linked...

  • Please help me with writing this code, it's R. Summarizing data 11 Now that you've seen...

    Please help me with writing this code, it's R. Summarizing data 11 Now that you've seen the function sapply() , you'll practice writing your own functions to apply! The first step is defining a function that ouputs summary statistics. Packaging common operations into functions allows you to avoid repeating yourself. To define your own function in R, you'll use the syntax function_name <- function(args, more_args) { } where the is replaced with whatever operations using args and more_args you want...

  • ***NEED SOLUTION IN PYTHON *** 1. Create a main function which only gets executed when the...

    ***NEED SOLUTION IN PYTHON *** 1. Create a main function which only gets executed when the file is directly executed Hint: def main(): pass if __name__ == '__main__': main() 2. Your programs will use a file called scores.txt to store a bunch of user-provided numbers. These can be int or float but their values must be between 0 and 100. Inside the main function, display the current list of numbers to the user and ask if they want to update...

  • I need help making this work correctly. I'm trying to do an array but it is...

    I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...

  • All to be done in C++ no user input is required. Just need to create vectors...

    All to be done in C++ no user input is required. Just need to create vectors and create functions to manipulate them as described. Search 2D Vector - Part 2 Write a C++ program that uses a function to search a 2D vector of floats. The function will have 2 parameters: 1. A 2 dimensional vector of floats, v 2. The floating point number that you are searching for, item Rewrite the Search_2D_Vector function so that it can work with...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT