thanks technocrat
I do use functions already.
However, I mean I don't want the same title on the plots.
I give you a somewhat better reprex (but for now without any data), so you won't see the graphs, ok?
model1data <- data.frame(mm(depvar, choice ~ somesthing + somesthingelse ,
id = ~uid, design=conjoint_design, baselines = baselines_base))
checkfunction(model1data)
#ENTER DF here:
model1data<- setDT(model1data)
is.data.table(model1data)
model1data<- preparefunction(model1data)
#my preparefunction sets the values underneath
if(is.combined==FALSE & is.somesthingelse==TRUE & is.eb==TRUE & is.ex == FALSE){s <- 16}
if(is.combined==FALSE & is.somesthingelse==TRUE & is.eb==FALSE & is.ex == FALSE){s <- 17}
if(is.combined==FALSE & is.somesthingelse==TRUE & is.ex == TRUE){s <- 15}
if(is.combined==FALSE & is.somesthingelse==FALSE & is.ex == TRUE){s <- 0}
if(is.combined==FALSE & is.somesthingelse==FALSE & is.ea ==TRUE & is.ea == FALSE){s <- 1}
if(is.combined==FALSE & is.somesthingelse==FALSE & is.ea ==FALSE & is.ea == FALSE){s <- 2}
p_model1data <- ggplot(model1data, aes(x = level, y = estimate, color=somesthingelse)) +
geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), shape = s) +
theme_bw() +
facet_wrap(something ~ ., scales = "free_y", nrow = 5, strip.position = "left") +
coord_flip() +
ylab("Always the same") +
xlab("Always the same2") +
# ylim(-0.3,0.3)+
geom_hline(yintercept = 0.5, lty="dashed") +
ggtitle("Actually it would be awesome if title would change according to input i.e. is.ex and is.ea and obs") +
if(is.ex==FALSE){scale_colour_manual(col="#4EC150", col="#330042")} # it actually would be helpful if colors could be linked to specific inputs
p_model1data
ggsave(filename="p_model1data.pdf", plot=last_plot())
# C ------------------------------------------------------------------
subset <- tt
setDT(subset)
subset <- subset[is.ea==1&is.ex==0]
model3data <- data.frame(mm(df_conj, depvar, choice ~ somesthing + somesthingelse
id = ~uid, design=conjoint_design, baselines = baselines_base))
checkfunction(model2data)
#ENTER DF here:
model2data<- setDT(model2data)
is.data.table(model2data)
model2data<- preparefunction(model2data)
#the names of my data frames are not like here, but convey a meaning!
#i.e. NO number that just goes up
if(is.combined==FALSE & is.somesthingelse==TRUE & is.eb==TRUE & is.ex == FALSE){s <- 16}
if(is.combined==FALSE & is.somesthingelse==TRUE & is.eb==FALSE & is.ex == FALSE){s <- 17}
if(is.combined==FALSE & is.somesthingelse==TRUE & is.ex == TRUE){s <- 15}
if(is.combined==FALSE & is.somesthingelse==FALSE & is.ex == TRUE){s <- 0}
if(is.combined==FALSE & is.somesthingelse==FALSE & is.ea ==TRUE & is.ea == FALSE){s <- 1}
if(is.combined==FALSE & is.somesthingelse==FALSE & is.ea ==FALSE & is.ea == FALSE){s <- 2}
p_model2data <- ggplot(model2data, aes(x = level, y = estimate, color=somesthingelse)) +
geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error), shape = s) +
theme_bw() +
facet_wrap(something ~ ., scales = "free_y", nrow = 5, strip.position = "left") +
coord_flip() +
ylab("Always the same") +
xlab("Always the same2") +
# ylim(-0.3,0.3)+
geom_hline(yintercept = 0.5, lty="dashed") +
ggtitle("Actually it would be awesome if title would change according to input i.e. is.ex and is.ea and obs") +
if(is.ex==FALSE){scale_colour_manual(col="#4EC150", col="#330042")} # it actually would be helpful if colors could be linked to specific inputs
p_model2data
ggsave(filename="p_model2data.pdf", plot=last_plot())
# Combine 1 & 2 ------------------------------------------------------------------
model_c_data <- data.frame(bind_rows(model2data, model1data, .id = "idies"))
checkfunction(model_c_data)
model_c_data<- setDT(model_c_data)
is.data.table(model_c_data)
model_c_data<- preparefunction(model_c_data)
p_model_c_data <- ggplot(model_c_data, aes(x = level, y = estimate, color=idies)) +
geom_pointrange(aes(min = estimate - 1.95 * std.error, max = estimate + 1.95 * std.error, shape = idies)) +
theme_bw() +
facet_wrap(something ~ ., scales = "free_y", nrow = 5, strip.position = "left") +
coord_flip() +
ylab("Marginal Means") +
xlab("Attributes") +
# ylim(-0.3,0.3)+
geom_hline(yintercept = 0.5, lty="dashed") +
ggtitle("Would be awesome if this title knew it were a combined plot")
if(is.ea==TRUE & is.somesthingelse == TRUE){ p_model_c_data <- p_model_c_data + scale_shape_manual(values=c(17,16))}
if(is.ex==FALSE){p_model_c_data <- p_model_c_data + scale_colour_manual(values=c( "#330042","#4EC150"),aesthetics = "colour")}
if(is.combined==TRUE & is.ex==FALSE){p_model_c_data <- p_model_c_data + scale_shape_manual(values=c(2,1))}
geom_text(aes(label = is.ea), colour = "black", size = 2.5, hjust=1.05, vjust=1.2)
p_model_c_data
ggsave(filename="p_model_c_data.pdf", plot=last_plot())