Requirements This lab assignment has two parts, each asking you to define a func

Requirements
This lab assignment has two parts, each asking you to define a function in R that solves
a specific business problem. Each part is worth 5 points with a total of 10 points. The detailed
requirements are listed below.
Part 1: Inventory replenishment
In your RStudio interface, open a new R Script window. (Check Lesson 1.2.4 for
instructions on running R scripts.) Define an R function named unit() that calculates the
number of weekly units that Mary Fresh needs for a particular product to replenish her inventory
with the following three arguments:
β€’ sales: the annual sales revenue of the product (required)
β€’ unit_cost: the per-unit cost of the product (required)
β€’ profit: the profit margin (optional with the default value of 0.05)
The number of units is calculated by: 𝑒𝑛𝑖𝑑 = π‘ π‘Žπ‘™π‘’π‘  βˆ— (1 βˆ’ π‘π‘Ÿπ‘œπ‘“π‘–π‘‘)/(𝑒𝑛𝑖𝑑_π‘π‘œπ‘ π‘‘ βˆ— 52).
Please make sure your function rounds any decimal answers to the nearest whole number.
Execute your codes to define the function. Write an R statement in your script window to test it
using sales = 10000 and unit_cost = 15.5. Your function should return 12.
Save your script file as Lab6FirstNameLastName.R to your computer (or to your U:
drive if you are using the Foster Remote Lab).
Part 2: Ad revenue
In the same R Script window, define a new function named revenue() that calculates
the annual revenue that a YouTuber makes with the following five arguments:
β€’ videos: the number of videos the YouTuber publishes in a year (required)
β€’ views: the average number of views for each video (required)
2
β€’ conversion: the conversion rate, i.e., the percentage of views that generate
impressions (optional with the default value of 1)
β€’ CPM: YouTube’s CPM (optional with the default value of 8.50)
β€’ commission: YouTube’s commission rate (optional with the default value of 0.45)
Where π‘Ÿπ‘’π‘£π‘’π‘›π‘’π‘’ = π‘£π‘–π‘‘π‘’π‘œπ‘  βˆ— 𝑣𝑖𝑒𝑀𝑠 βˆ— π‘π‘œπ‘›π‘£π‘’π‘Ÿπ‘ π‘–π‘œπ‘› βˆ— (𝐢𝑃𝑀/1000) βˆ— (1 βˆ’ π‘π‘œπ‘šπ‘šπ‘–π‘ π‘ π‘–π‘œπ‘›).
Please round the return result to the nearest hundredth.
Execute your code to define the function. Write an R statement in your script window to
test it using videos = 48, views = 21300. Your function should return 4779.72. Save your work.
Your file should include both the functions and the test statements.

Posted in R

Place this order or similar order and get an amazing discount. USE Discount code β€œGET20” for 20% discount