My goals for this week:
Each week, I aim to change the theme of my learning log because I like variety, but the default themes are very similar (and a littleeeee bit drab). So this week, I found a way to change the default theme setting by downloading the prettydoc package and replacing the html_document output engine with prettydoc::html_pretty. I chose the hpstr theme and I love the colours - it is so pretty!!!! The only downside was that the toc_float function cannot be applied with the html_pretty output engine, so I couldn’t have a floating table of contents like I usually do.
My other goals for this week was to continue meeting with my assignment group and reproducing the statistics and graphs from our COVID paper. I also worked on refining my code and adding more comments to document my progress.
Successes and challenges:
The meetings my group had this week were really successful, as we managed to recreate the data from our assigned studies. We worked really well as a team and we helped each other find solutions to problems/gaps in our code by using the knowledge we have acquired from this course and a little help from Google.
Also since study 4 was the longest and most convoluted study in our COVID paper, Victoria and I worked on re-creating the data from that study together and she did an amazing job with the graph! I was able to add in the colours thanks to Jasmin finding the exact ones we needed, which was amazing!
The main challenges I had this week were that I really struggled to import the data I needed to for study 4. My group recommended that I download the RStudio app onto my computer (which I had been meaning to do for a while now) and it was life-changing!
Additionally, with the graph above, I wasn’t sure how to individually label each condition on the x-axis. However, after Jasmin suggested using the “scale_x_discrete” function and I used the theme(axis.title.x = element_blank() function, we were able to remove the general x-axis label and make the violin box plots look exactly like the ones in our COVID paper!
# Changing study conditions from numeric variables into factors
study4$bed <- as.factor(study4$bed)
# Creating the plot
ggplot(data = study4,
aes(
x = bed, # <- The variable name in SPSS for the experimental conditions
y = Q22_1 # <- The variable name in SPSS for the question used for measuring mask wearing
)) +
geom_violin(
aes(
fill = bed
)
) +
geom_boxplot(width = 0.1) +
stat_summary(fun = mean, geom = "point", shape = 9,
size = 2) + # added the mean diamond within the boxplot
scale_fill_manual(values = c("#a4cee4", "#1578b5",
"#b3d789")) + theme(legend.position = "none") + scale_x_discrete(labels = c("Control","Information Only","Empathy")) + scale_y_continuous("Motivation to Wear a Face Mask") + theme(axis.title.x = element_blank()) # Removed general x-axis title so that the labels for each experimental condition (state empathy) remained Questions for next week’s Q and A session:
Although my group has done such an amazing job with re-creating the data from our COVID paper so far, we have a few questions for the Q and A next week:
- After using the grid.arrange function, how do we give common x- and y-axis labels to multiple plots that we have combined together?
Graph for study 1
As you can see in the image above, there are titles and axis labels on each graph, but we want to have just one ‘physical distancing’ and ‘empathy’ label across the three graphs.
- Is there a way can reorder the factors on this violin box plot?
Graph for study 3
The ‘information only’ violin is meant to be in the middle and the “info+empathy” violin is meant to be on the right. The problem is that “information only” is set at 1 and “info+empathy” is set at 2, so when plotted, “information only” is to the left of “info+empathy”, but should be on the right. Is there a way we can fix this?
- Is there a way I can make the presentation of the study 4 code (shown underneath “successes and challenges”) at the bottom look a bit nicer? When I knit this Rmarkdown and/or put the code into a HackMD, it is shown in one super long line and I have to scroll far to the right in order to see it. I am sure there is a really simple solution to this, but whenever I have tried to make it appear less clunky, it comes up with formatting errors.
I hope these questions make sense, but feel free to Slack me if you need me to clarify anything :)
Next steps in my coding journey:
During flexibility week, I plan to continue communicating with my group and working towards completing our data re-creation so that we will have plenty of time to prepare for our presentation in week 8! I will also attend the Q and A session that will be running on Tuesday, as Jenny has been super helpful with our coding questions so far.