library(readr)
labtest <- read_csv("C:/Users/cbado/OneDrive/Documents/R Code/labtest.csv")
labtest$region <- as.factor(labtest$region)
library(ggplot2)
library(cowplot)
ggplot(labtest, aes(x="", y=sales)) + geom_boxplot(fill="#0076B6",)+ggtitle("Sales for All Sectors & Regions")+xlab("All Sectors & Regions")+ylab("Sales (thousands)")+scale_y_continuous(labels=scales::dollar_format())
ggplot(labtest, aes(x="", y=profit)) + geom_boxplot(fill="#B0B7BC",)+ggtitle("Profit for All Sectors & Regions")+xlab("All Sectors & Regions")+ylab("Profit (thousands)")+scale_y_continuous(labels=scales::dollar_format())
ggplot(labtest, aes(x="", y=newinvest)) + geom_boxplot(fill="#32CD32",)+ggtitle("New Investment for All Sectors & Regions")+xlab("All Sectors & Regions")+ylab("New Investment (thousands)")+scale_y_continuous(labels=scales::dollar_format())
ggplot(labtest, aes(x=region, y=sales, fill=region)) + geom_boxplot()+ggtitle("Sales by Region")+xlab("Region")+ylab("Sales (thousands)")+scale_y_continuous(labels=scales::dollar_format())+scale_fill_manual(values=c("#FFC906","#223971"))+labs(fill = "Region")
ggplot(labtest, aes(x=region, y=profit, fill=region)) + geom_boxplot()+ggtitle("Profit by Region")+xlab("Region")+ylab("Profit (thousands)")+scale_y_continuous(labels=scales::dollar_format())+scale_fill_manual(values=c("#FFC906","#223971"))+labs(fill = "Region")
ggplot(labtest, aes(x=region, y=newinvest, fill=region)) + geom_boxplot()+ggtitle("New Investments by Region")+xlab("Region")+ylab("New Investment (thousands)")+scale_y_continuous(labels=scales::dollar_format())+scale_fill_manual(values=c("#FFC906","#223971"))+labs(fill = "Region")
ggplot(labtest, aes(x=sales, y=profit, color=region)) + geom_point()+ggtitle("Profit by Sales")+xlab("Sales")+ylab("Profit")+scale_y_continuous(labels=scales::dollar_format())+scale_x_continuous(labels=scales::dollar_format())+scale_color_manual(values=c("#FFC906","#223971"))+labs(color = "Region")+stat_smooth(method = "lm", formula = y ~ x, size = 1)
ggplot(labtest, aes(x=newinvest, y=sales, color=region)) + geom_point()+ggtitle("Sales by New Investment")+xlab("New Investment")+ylab("Sales")+scale_y_continuous(labels=scales::dollar_format())+scale_x_continuous(labels=scales::dollar_format())+scale_color_manual(values=c("#FFC906","#223971"))+labs(color = "Region")+stat_smooth(method = "lm", formula = y ~ x, size = 1)
ggplot(labtest, aes(x=newinvest, y=profit, color=region)) + geom_point()+ggtitle("Profit by New Investment")+xlab("Profit")+ylab("Sales")+scale_y_continuous(labels=scales::dollar_format())+scale_x_continuous(labels=scales::dollar_format())+scale_color_manual(values=c("#FFC906","#223971"))+labs(color = "Region")+stat_smooth(method = "lm", formula = y ~ x, size = 1)
library(DataExplorer)
library(tidyverse)
plot_correlation(labtest %>% select(profit, sales, newinvest))
From the correlation map of profit, sales, and new investment, it can be concluded that while new investments do drive growth in sales, they only contribute to profit growth at half the rate, on average. Also, as sales grow in general, profitability does not necessarily grow at the same rate, perhaps due to costs contributed by meeting increased sales volumes.
Region <- c("1", "2")
Count <- c(nrow(labtest[labtest$region == "1",]), nrow(labtest[labtest$region == "2",]))
q4 <- data.frame(Region, Count)
ggplot(q4, aes(x = Region, y = Count, fill = Region)) + geom_bar(stat =
"identity") + ggtitle("Number of Records by Region") + xlab("Region") +
ylab("Number of Records") + scale_fill_manual(values = c("#FFC906", "#FF4300"))+geom_text(aes(label=Count), position = position_stack(vjust = 0.5))