We pairwise matched participants from two different language groups based on age/sex/etc with Optmatch, creating new variable "matches" that contains an exact label for each pairwise match.
i.e. matches
18.M.1 18.M.1 18.M.16.1 18.M.16.1 18.M.18.1 18.M.18.1 19.F.1 19.F.1 19.M.1 19.M.1
And created bar plots representing each language group's scores on our dependent variable (Total_Vocabulary).
Now, I wish to connect scores (represented as dots in the graphs) in language group 1 (trilingual) to the scores of their respective match in language group 2 (bilingual), however I cannot seem to find any past studies who have done this nor the code to do this in R.
Any help would be greatly appreciated.
Tried to add geom_line argument in the code below and got message
Error: Aesthetics must be either length 1 or the same as the data (2): y
Code without error:
#plot the data
barplot_summary_18 <-
keepers_matched_18m %>%
#filter(domain == "Home Reading Environment") %>%
group_by(Lang_Group) %>%
#filter(!is.na(score)) %>%
summarise(SD = sd(Total_Vocabulary), Total_Vocabulary = mean(Total_Vocabulary), n = length(unique(Sub_ID))) %>% # Get all the means
mutate(SE = SD/sqrt(n))
#bargraph for T-Tests
ggplot(barplot_summary_18)+
geom_bar(stat="identity", position = "dodge", aes(x= Lang_Group, y = Total_Vocabulary, fill = Lang_Group)) +
geom_point(data = keepers_matched_18m,aes(x= Lang_Group, y = Total_Vocabulary, fill =Lang_Group), color = "black", stat = "identity",position=position_jitterdodge(), pch = 21, alpha = .5)+
geom_errorbar(aes(x = Lang_Group, ymin = Total_Vocabulary - SE, ymax = Total_Vocabulary + SE, fill = Lang_Group),
width=0.2,position=position_dodge(.9), color = "black") +
scale_fill_manual(values = c("#f1a340", "#998ec3"), name = "Language Group", labels = c("Bilingual", "Trilingual")) +
ylab("Total Vocabulary") +
xlab("Group") +
ggtitle("Total Vocabulary by Language Group - 18 month included")+
theme_bw(base_size=12)+
theme(axis.text.x = element_text(angle = 0, hjust = .5, size = 10),
axis.title.x = element_text(size = 14),
axis.text.y = element_text(angle = 0, hjust = .5, size = 10),
axis.title.y = element_text(size = 14),
plot.title = element_text(hjust = .5, size=16),
legend.text=element_text(size=12))+
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())