Question

In: Computer Science

# FOR THE NEXT FEW QUESTIONS YOU WILL WORK WITH THE TEN SEGMENTS DATA FROM PART...

# FOR THE NEXT FEW QUESTIONS YOU WILL WORK WITH THE TEN SEGMENTS DATA FROM PART 1 OF THE EXAM. THE DATA ARE LOCATED ON Canvas.

10) Write code to import TenSegments.csv into R as a data frame tensegments

11) Write code that creates a new column with the CLV for all segments using formula 1. Assume a discount rate of 10%.

12) Write a for loop that loops through all the CLV values and creates a new vector that contains any CLV values that are negative

# FOR 1 BONUS POINT: # Write 1 line of code that calculates the average acquisition cost for the 3 segments with the highest CLV. You cannot hard code any values into your code.

Solutions

Expert Solution

STEP - BY - STEP PROCESS

(10.) Since I have no dataset, So I have created this one. You can import your csv dataset like this ==>

df <- read.csv("location of the csv file", header = TRUE)
Segment <- as.numeric(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
AcquisitionCost <- as.numeric(c(177.25, 37.49, 156.11, 171.23, 89.86,
                                135.26, 139.99, 129.07, 125.44, 173.22))
RetentionRate <- as.numeric(c(0.95, 0.5, 0.8, 0.85, 0.55, 0.7, 0.75, 0.65, 0.6, 0.9))
Margin <- as.numeric(c(1911.26, 715.83, -400.5, -292.51, -290.5,
                       2957.98, 2890.01, 2224.93, 1.65, 420.51))
df <- data.frame(Segment, AcquisitionCost, RetentionRate, Margin)
df

Output:

(11.) Write code that creates a new column with the CLV for all segments using formula 1. Assume a discount rate of 10%.

discount_rate = 0.10
df['CLV'] <- ((df$Margin * df$RetentionRate) / (1 + discount_rate - df$RetentionRate)) - df$AcquisitionCost
df

Output:

(12.) Write a for loop that loops through all the CLV values and creates a new vector that contains any CLV values that are negative.

negative_CLV <- c()
for (i in 1:length(df$CLV)) { 
    if (df$CLV[i] < 0) {
        negative_CLV[i] <- df$CLV[i]
    }
}
negative_CLV <- na.omit(negative_CLV)
for (i in 1:length(negative_CLV)) { 
    print(negative_CLV[i])
}

Output:

(13.) code that calculates the average acquisition cost for the 3 segments with the highest CLV.

df1 <- head(df[with(-df, order(CLV)), ], 3)
mean(df1$AcquisitionCost)

Output:

NOTE: Please use R-Studio for better understanding !!!

Thumbs Up Please !!!


Related Solutions

For questions the next few questions, please respond to the following questions with regard to the...
For questions the next few questions, please respond to the following questions with regard to the following scenario. Becky would like to sell her 2003 Ford Ranger. She advertised the truck at $3,800 in the local newspaper. She hopes to sell it for $3,500. The lowest price she will accept before selling is $3,300. If she doesn’t receive an offer of at least $3,300, she will donate her truck to charity for a tax deduction. Alec would like to buy...
Example 38: The following data should be used for the next few questions: Raw materials inventory,...
Example 38: The following data should be used for the next few questions: Raw materials inventory, January 1 $ 12,000 Raw materials inventory, December 31 16,000 Work in process, January 1 5,000 Work in process, December 31 8,000 Finished goods, January 1 17,000 Finished goods, December 31 12,000 Raw materials purchases 118,000 Direct labor 165,000 Factory utilities 64,000 Indirect labor 12,000 Factory depreciation 18,000 Selling and administrative expenses 220,000 How much is the cost of the direct materials used? a....
For the next few questions, consider the market for a type of equipment used by crafting...
For the next few questions, consider the market for a type of equipment used by crafting enthusiasts to cut out die-cut shapes. It's a specialized market, so we'll just have to assume we have enough buyers and sellers to have our demand and supply curves be straight, smooth lines. The following information applies to the market before any tax is applied: Vertical intercept, demand curve: 80 Vertical intercept, supply curve: 50 P* = $60 Q* = 40 Later, a tax...
A professor prepares ten questions for an exam. He makes multiple exams from these ten questions,...
A professor prepares ten questions for an exam. He makes multiple exams from these ten questions, so students do not all have the same test. On each test, he randomly selects five of the ten questions. a. How many different exams can the professor make assuming two exams with the same questions in different orders are counted as the same exam? Show the calculations used to determine the solution. b. How many different exams can the professor make assuming two...
The next two questions are part of the same scenario. You will use VLSM to design...
The next two questions are part of the same scenario. You will use VLSM to design an addressing scheme for a client who has the 185.33.64.0 /24 address block. (a) The largest host requirement is for LAN A, which requires 100 hosts. What would be the subnet address and prefix length for this subnet?
1. For the next few questions, consider a network formed by 500 students in a dorm...
1. For the next few questions, consider a network formed by 500 students in a dorm as the nodes. The edges in this network represent roommate relationships, i.e. two nodes are connected if they are currently roommates. In this form, the rooms are mostly double occupancy with a few triples and quads. What is the mode (most frequent value) of the node degrees? 2. Consider the aforementioned roommate network. How many nodes are in the largest clique in the network?...
You have just won a lawsuit and, as part of the judgement, you will be receiving semi-annual payments of $20,000 over the next ten years.
You have just won a lawsuit and, as part of the judgement, you will be receiving semi-annual payments of $20,000 over the next ten years. The first payment will occur six months from today. You plan on investing these payments and you expect to earn a return of 5% p.a. compounded on a monthly basis. The future value of this investment at the end of its time horizon is closest to:  $409,761.  $510,893.  $503,116. $512,242.
The next few questions relate to the discussion we had in class concerning a REITs financial...
The next few questions relate to the discussion we had in class concerning a REITs financial statements. For reference, please refer to the Excel file Problem Set 2, Tab FFO. So, getting on, let's make the following assumptions about a simplified REIT income statement. (All of the numbers are in millions). 250 in revenues; 100 in operating expenses; 50 in depreciation; 50 shares outstanding; 10 in Cap Expenditures; 40% tax rate. What is the REITs Adjusted Funds from Operations? 140...
Use the following information about the town of? Boone, NC to answer the next few questions....
Use the following information about the town of? Boone, NC to answer the next few questions. Suppose Boone has a total population of? 25,000 people. There are? 18,000 people who currently have a job. Another? 3,000 people do not have a job but are currently looking for one. Of those? 3,000 people, 500 of them recently quit and are looking for a job that suits their? skill-set, 1,000 of them were recently replaced by new machinery at the local ski?...
Use only the information in the following table for the next few questions.  The following statistics represent...
Use only the information in the following table for the next few questions.  The following statistics represent samples of copper wire submitted by two companies for tensile strength testing (psi). Statistic                                                      Company A          Company B Arithmetic Mean                                       500                         600 Median                                                       500                        500 Mode                                                           500                       300 Standard Deviation                                   40                          20 Mean Absolute Deviation                         32                        16 Quartile Deviation                                     25                         14 Range                                                       240                         120 Sample Size                                          100                           80 The middle 95% of the wires from Company A tested between _____ and _____ .  Record ONLY the lower limit as a whole number. The middle 50 percent of the wires of Company A tested...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT