#The following was the preliminary information I loaded and utilized for my working directory.
library(readr)
supermarket_sales <- read_csv("supermarket_sales.csv")
View(supermarket_sales)
library(dplyr)
library(janitor)
getwd()
setwd("C:/Users/brand/OneDrive/Documents/Spring 2023/AREC 330/Problem Set 2")
Calculate the total value of the sale using the unit_price and quantity columns. Name the new column subtotal. Then verify that the value labeled tax_5_percent is indeed 5% of the subtotal by creating a new variable called tax_verify. Assign the object to a new dataframe.
supermarket_raw <- clean_names(supermarket_sales)
newdata <- mutate(supermarket_raw,subtotal=unit_price*quantity)
newdata <- mutate(newdata,tax_verify=subtotal*0.05)
2. Create a dataframe containing only the subset of sales from the product line Food and beverages.
subset_of_sales <- filter(supermarket_raw,product_line=="Food and beverages")
3. Create a dataframe containing only the columns city, product_line, unit_price, quantity, total, rating from the product line Food and beverages.
refined_food_beverages <- select(subset_of_sales,city, product_line, unit_price, quantity, total, rating)
4. Sort the dataframe quantity by subtotal in descending order.
newdata_sorted <- arrange(newdata,quantity,desc(subtotal))
5. Generate a log file from your script. See the section in the lab file for reference.
sink("log.txt")
print(supermarket_raw)
print(newdata)
print(subset_of_sales)
print(refined_food_beverages)
print(newdata_sorted)
sink()
What type of connection did you use to connect to supermarket_sales.csv?
In order to connect to supermarket_sales.csv I used a file based connection.
2. What type of data is supermarket_sales.csv?
supermarket_sales.csv is spreadsheet data.
3. How many sheets are included in supermarket_sales.csv?
supermarket_sales.csv contains 1 sheet.
4. How many data fields are included in supermarket_sales.csv?
supermarket_sales.csv contains 17 data fields.
5. What is the role of the variable City?
The role of the variable City is dimensional, or that it serves that of a qualitative purpose to classify data based on location.
6. What is the type of the variable City?
As a dimensional variable, City is a geographic form of data.
7. What is the role of the variable Total?
The role of the variable Total is measurable, or that it serves a quantitative purpose in order to assess multiple variables.
8. What is the type of the variable Total?
The variable Total is an integer form of data.
9. Create a data visualization that shows total spending by all customers in each city a store is located in. Give your sheet and figure a useful title and ensure that axes labels are easy to read and informative. What did you find? Discuss how the stores could use this information to increase sales.
By separating out total spending per city location, we were able to find that for Mandalay and Yangon they have a comparable amount in sales. For Naypyitaw, however, they have an increased number of sales that totals just slightly over $4,000 more. Stores could use this information in a couple of ways. One, if they wanted to figure out where in which they could allocate more resources to increase sales, they could see that Mandalay and Yangon could use these additional funds for marketing tactics while Naypyitaw receives less attention. Another way stores could use this information is by figuring out where demand is strongest in preexisting locations. This ties hand in hand with our previous suggestion, but in the capacity that stores could track where they need keep and maintain sales. Overall, you put this information together and it can provide you with a tool to see where resources can be allocated and also where your current business is most successful. These tools can contribute to developing a better financial picture that better informs business decisions.
10. Create a data visualization that shows total spending for males and females in each city a store is located in. Give your figure a useful title and ensure that axes labels are easy to read and informative. What did you find? Discuss how the stores could use this information to increase sales.
In analyzing the given bar graph, we are able to see that while sales are very similar for Mandalay and Yangon across genders, for Naypyitaw they have a much different portfolio of consumers. As mentioned in question 10, you need to know where your sales are strongest and how that information can influence your overall financial picture. Here this shows a very similar picture. Mandalay and Yangon, while they could reap the benefits of increased marketing to increase sales, we can also see that our current marketing structure is attracting both male and female individuals. For Naypyitaw on the other hand, we already have a very strong female customer base, so while we want to protect this market, we also now know that there is more we may need to consider for our male target market. This could help pull up sales and spending my male consumers and balance out our total sales figures.
11. Title your two sheets ‘PS2 Q9’ and ‘PS2 Q10’, save your workbook, and publish it to your Tableau Public site.
https://public.tableau.com/app/profile/brandon.dodd