我想添加趋势线,以便在按地理位置划分时查看各个季度的趋势。这是我想添加趋势线的情节。
Quart <- c("Q1", "Q2", "Q3", "Q4", "Q1", "Q2", "Q3", "Q4" )
Locate <- c("US", "Other", "US", "US", "Other", "US", "US", "Other")
Product_Price <- c(10, 25, 36, 153, 23, 20, 96, 785)
Product_ID <- c("helme[enter image description here][1]t", "gloves", "jacket", "helmet", "jacket", "glasses", "hoody", "gloves")
df <- data.frame (Quart, Locate, Product_ID, Product_Price)
df$Quart <- as.factor(df$Quart)
df$Locate <- as.factor(df$Locate)
#Price data Over Quarters by Location
library(ggplot2)
ggplot(df, aes(x = df$Quart, y = df$Product_Price, fill = Locate)) +
geom_bar(stat="identity", position=position_dodge()) +
labs(x = "Quarter", y="Product Price", title = "Price over Quarter and Location") +
scale_fill_hue(name="Product Type") +
facet_wrap(~Locate)