Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedPLEASE 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago