Example:
In order for this code to function, your data must be structured in a manner which resembles the following graphic:
The following code below will create the example’s associated data frame with the R-Programming Language.
Satisfaction = c(7, 2, 10, 2, 2, 8, 5, 1, 3, 10, 9, 10, 3, 10, 8, 7, 5, 6, 4, 10, 3, 6, 4, 7, 1, 5, 5, 2, 2, 2)
StudyTime = c('One Hour', 'One Hour', 'One Hour', 'One Hour', 'One Hour', 'One Hour', 'One Hour', 'One Hour', 'One Hour', 'One Hour', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Two Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours', 'Three Hours')
School = c('SchoolA', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolA', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolB', 'SchoolB')
School_Sat = data.frame(Satisfaction, StudyTime, School)
##############################################################
# Getting the Libraries in Order (for Graphical Output) #
# Load Package #
library(ggpubr)
# Mean and Standard Error #
ggline(subset(School_Sat),
x = "StudyTime",
y = "Satisfaction",
color = "School",
add = c("mean_se") # add mean and standard error #
) +
labs(y = "Satisfaction")
ggline(subset(School_Sat),
x = "StudyTime",
y = "Satisfaction",
color = "School",
add = c("mean") # add mean only #
) +
labs(y = "Satisfaction") +
ggtitle("Your Title Here") +
theme(plot.title = element_text(hjust = 0.5))
##############################################################
To create a customized graphic which contains attributes more specific to your research, please consult the "ggpubr" manual. This can be found online.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.