Question: PLEASE USE R STUDIO OR / AND UPLOAD R SCRIPT Q1(10 points): Use while loop to calculate the product of all numbers from 50 to

PLEASE USE R STUDIO OR / AND UPLOAD R SCRIPT Q1(10 points):Use while loop to calculate the product of all numbers from 50PLEASE USE R STUDIO OR / AND UPLOAD R SCRIPT

Q1(10 points): Use while loop to calculate the product of all numbers from 50 to 100 . Redo it using for loop. Q2 (10 points): Write a function f(x) that returns absolute value of x, that is: If x is positive, then f(x)=x If x is negative, then f(x)=x Q3 (10 points) In RStudio, please copy the following concatenate strings mydata =c ("This is me", "That my house", "Hel10, world!") Please use "regular expression" code to print out only last line (e.g. "Hello, world!")) [hint: use str_detect and $ or ] Q4 (10 points) In RStudio, please copy the follow concatenate strings Please use "regular expression" code to print out only phone numbers (e.g. last three items) [hint: use str_extract and 1 d or .] Q5 (Bonus 20 points) In time-series finance and technical analysis, moving average is a very important concept. Particularly, a n-day simple moving average ( n-day SMA) is the arithmetic average of prices of past n days at loday 1 : SMAt(n)=nPt++Ptn+1 Write a function (for instance, you can name the function as mySMA) to calculate 5 -day moving average for the past 10 days. Suppose the prices of past 10 days are 1:10 (e.g. 1,2,3,..10). The following is solution hint to help you finish: mySMA

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!