@andresrcs
#This is phase 1 finished product. Amazing, thank you R community!
#I was not allowed to copy or attach the graph because I am a new user (I think).
df <- tibble::tribble(
~Product.Code, ~Product.Name, ~Price,
"AA22", "blah1", 2.12,
"AA22", "blah1", 2.42,
"AA22", "blah1", 4,
"AA22", "blah1", 3.50,
"AA22", "blah1", 5.35,
"BB33", "blah2", 5.54,
"BB33", "blah2", 3.42,
"BB33", "blah2", 4.34,
"CC23", "blah3", 100.23,
"CC23", "blah3", 25.23,
"CC23", "blah3", 105.25
)
df_tibble <- as_tibble(df)
rm("df")
#I have so much data and hence so many product codes that I had to subset the product codes for
#each set of product codes to make individual graphs for select product codes. I had too much data
#for @andresrcs original suggested code.
#L0021
AA22_t <- subset(df_tibble,df_tibble$Product.Code=="AA22")
AA22_t
AA22String <- "AA22"
AA22String
#Boxplot code. You can change the color of the boxplot to your taste. Red dot is the average price.
#Next step is to come up with a legend for red dot representing average prices
library(ggplot2)
ggplot(AA22_t, aes(x = "", y = Price, fill = Product.Code)) +
geom_boxplot(fill = 'lightcyan') +
stat_summary(fun.y=mean, geom = "point", shape = 20, size = 7, color = "red", fill = "red") +
geom_point(position = 'jitter') +
coord_flip() +
labs(x = "") +
labs(title = AA22_t$Product.Name) +
labs(subtitle = AA22_t$Product.Code)
#Pastecs includes descriptive stats function stat.desc
install.packages("pastecs")
library (pastecs)
#To undo scientific notation and to revert back below:
options(scipen=999)
#options(scipen=0)
#Descriptive statistics to 5 decimal places
options(digits= 5)
stat.desc(AA22_t$Price)
