Hi!
I am not quite sure I understand ggplot's mapping. I like the look of the box plot from the Boxplot function in the car package but it doesn't take a horizontal command and I'd like to understand how to use ggplot for this purpose. I've provided example code and the Boxplot code as well for comparison.
I basically want to just map a boxplot of the sub_scale item but retain the student_ID's in the data set to be able to trace down outliers. I just don't understand how to do this without having the student_ID values become part of the chart. If I am not clear enough about what I am asking please let me know and I will try to clarify further but hopefully the example will be helpful.
sub_scale <- c(1.00 , 3.45, 3.00, 3.00, 3.00, 3.24, 4.00, 17, 22, 75)
student_ID <- c(1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009)
xData <-data.frame(sub_scale, student_ID) #data
# Notice that student_ID values are being used
xData%>%
ggplot( aes(x= student_ID, y=sub_scale, fill=sub_scale)) +
geom_point() +
geom_boxplot() +
stat_boxplot(geom = "errorbar") +
theme_ipsum() +
theme(legend.position="none")+
coord_flip() +
xlab("") +
ylab("")
## Even if I try pivot longer it doesn't quite do it...
DFplot <- xData %>%
pivot_longer(cols = c("student_ID", "sub_scale"), names_to = "text", values_to = "value")
DFplot%>%
ggplot( aes(x= text, y= value)) +
geom_point() +
geom_boxplot() +
stat_boxplot(geom = "errorbar") +
theme_ipsum() +
theme(legend.position="none")+
coord_flip() +
xlab("") +
ylab("")
# Here is the graph I'd like to mimic with ggplot only have it displayed horizontally
library(cars)
Boxplot(Data$slf_eff_T1,
main = "Self Efficacy",
xlab = "Response Values",
ylab = "Self Efficacy",
col = "orange",
border = "brown")