<- function(Total_Estimated_Revenue) {
Employee_Wages
ifelse(Total_Estimated_Revenue < 500000, stop("error: no data for this revenue range"),
<- ifelse(Total_Estimated_Revenue < 999999.99, .0789,
percentage ifelse(Total_Estimated_Revenue < 2499999.99, .0934,
ifelse(Total_Estimated_Revenue < 4999999.99, .0751,
ifelse(Total_Estimated_Revenue < 24999999.99, .0975, .1083)))))
* percentage
Total_Estimated_Revenue }
Grocery Project:
This week was centered on converting the sheets that our client gave us to useful functions for our project package. My functions were R translations of our clients sheet for estimating expenses of potential rural grocery stores.
So far, there are 8 functions that are derived from the expense estimation sheet, yet it is still a work in progress. Here are the ones we have so far:
Cost_of_Goods_Sold()
Gross_Margin()
Officer_Compensation()
Employee_Wages()
Other_Operating_Expense()
Operating_Income_Loss()
Annual_Rent()
Interest_Expense()
Many of these functions give different outputs based on the range that the input for total estimated revenue falls into. Here, the revenue ranges are listed in a table with the corresponding percentages for each variable (in decimal form):
Therefore, some of our functions required a way to account for these differences. As it stands, this is dealt with through nested ifelse statements.
It’s likely that more work needs to be done for error handling in functions like these.
Here’s a function that depends on some other functions in the package:
<- function(Total_Estimated_Revenue) {
Operating_Income_Loss <- Cost_of_Goods_Sold(Total_Estimated_Revenue)
Goods_cost <- Officer_Compensation(Total_Estimated_Revenue)
Officer_comp <- Employee_Wages(Total_Estimated_Revenue)
Employee_Wages <- Other_Operating_Expense(Total_Estimated_Revenue)
Other_Expense
- sum(Goods_cost, Officer_comp, Employee_Wages,
Total_Estimated_Revenue
Other_Expense) }
Most of the functions only take one argument: Total Estimated Revenue. This will be calculated from the functions made from our revenue estimation sheet (Srika). Other functions, such as Annual_Rent() or Interest_Expense(), have inputs that are dependent upon a user’s individual scenario, such as the size of a loan or the rate of monthly rent for the building.
There are still questions left to be answered, such as how to precisely estimate the cost of depreciation and how to determine the correct use life of certain assets. However, our team all made significant progress this week.
Coffee Talk
I also learned a lot about text mining in R this week. I decided to compare the reviews from two gaming journalistic outlets for the past 5 Legend of Zelda games using certain text mining techniques. Some of the interesting libraries I learned about include:
tm
tidytext
RWeka
qdap
plotrix
rvest
wordcloud
syuzhet
Here are some plots from the project:
Many of the techniques used for the project was from the Datacamp course “Text Mining with Bag of Words in R” and “Sentiment Analysis in R”.
Overall, today has been a pretty good week.