Search for question
Question

# Homework

# Answer the following questions.

# Write your code in R below each question.

# Run the code to see it really works.

#

# Questions

# Run the codes to create the following vectors.

# This is a dataset about products, their inventory levels

# and unit costs at a company

productNames = c("x01","x02","y25", "y39", "z33", "z47", "z59")

inventoryLevels = c(1200, 1450, 1100, 900, 550, 730, 850)

product UnitCosts = c(11.50, 9.50, 13.00, 20.50, 25.00, 42.00, 35.00)

# 1) List first 3 product names

# 2) List inventory levels of product 2, 5, and 7

# 3) List cost of all products except 3 and 6

# 4) The company decided to discontinue product "z33". So, delete

# this product's name, inventory and cost information from the

# the dataset.

# 5) The company decided to make a new product called "x10" with

an initial inventory level of 100 and unit cost of 45.00 dollars.

Add this new product's information at the end of the dataset.

#

# 6) The company needs to know how much money is tied at the

inventory (ie. value of the inventory).

For this calculation, you need to write a long equation

multiplying each product's inventory level by the unit cost,

and adding up for all products. Print inventory value at the end.

HINT: invValue = inv1 * cost1 + inv2 * cost2 + ...

Fig: 1