I need to generate tick labels and hopefully titles in ggplots from a separate data frame that is a master list of variables and labels.
# LABELS
master_labels <- data.frame(
variable = c(
"v2_Q", "v3_X","v3_Y","v4_N","v4_O","v1_A","v3_Z","v4_M","v2_R",
"v1_B","v1_C","v2_S","v1_D","v1_E" ),
labels = c(
"Young Adult Male","Baby Girls","Toddler Girls","Sedan","SUV","Baby Boys",
"Little Girls","Minivan","Adult Male","Toddler Boys","Little Boys","Big and Tall Male",
"Big Boys", "Teen Boys"
))
master_labels
# TITLES
titles <- data.frame(
category = c("v1","v2","v3","v4"),
title = c("Boy's Department","Men's Department","Girl's Department","Automotive")
)
titles
# Data and Plot
df1 = data.frame(
variable = c("v2_Q","v3_X","v4_N","v4_O","v1_A","v3_Z","v4_M","v2_R","v3_Y",
"v1_B","v1_C","v1_D","v1_E","v2_S","v2_T","v3_W"),
means = c(0.5, 0.35,0.35, 0.35,0.3,0.3,0.3,0.25, 0.25,0.2,0.2, 0.15, 0.15,0.15,
0.1, 0.1 ))
df1
n=df1$variable
n
##### Data for Variable 1 Plot
ni = grepl("v1", n)
df1 = subset(df1, ni)
df1
plot1 = ggplot(data=df1) +
geom_col(aes(x=variable, y=means,fill=means), position=position_dodge())+
theme(axis.title.y=element_blank())+
labs(title = "Means of Variable ???",
y = "Mean") +
coord_flip()
plot1
Thanks for the help!