Question: The following two questions will mainly use if-else logic code: Q3(10 points) Given any number vectors, please write a short program to let R judge
The following two questions will mainly use if-else logic code: Q3(10 points) Given any number vectors, please write a short program to let R judge and print out odd or even for all numbers. For example: given A=c(4,2,2,1), write a program to let R give output: "even" "even" "even" "odd". You can input any numbers and set any length of the vector c(...),butthelengthshould be at least two numbers Q4(10 points) Suppose you have a vector of stock prices. Please write a short program to let R output "buy" or "sell" based on certain condition. For instance, suppose you have AAPL =C(109.49,109.90,109.11,109.95,111.03), write the program to judge decision. The threshold is that if the price is larger than 110.00 , R will show "sell", or it will show "buy". In this case, please write a program to let R judge and return "buy" "buy" "buy" "buy" "sell
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
