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

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

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("Thisisme", "That my house", "Hello, 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 mydata=c(NancySmith,isthereanysolution?,".[{($?+","coreyms.com","321-555-4321","123.555.1234","1235551234") Please use "regular expression" code to print out only phone numbers (e.g. last three items) [hint: use str_extract and \\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 today t : 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 you finish: mySMA n ) \{ Then you wish to compute the following mySMA(1:10,5) The result output should be

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!