Comparing the same indiviual in datatset

Dear all,

I'm a bit of in newby with R, so please be gentle (: Currently I am visualizing my data using boxplots (ggplot2). In my data set I have individuals (df$Fish_ID) who all are tested twice (df$Exposure) which is eighter "1" or "2". I've made multiple boxplot for different treatments and different treatment, all using all the data to compare. Is there is possiblity where I can compare the difference in mean( difference between Exposure1 vs Exposure 2) and make this visual in a boxplot? So for example; instead of comparing all the data of Exposure 1 vs Exposure 2, only compare this for every individual apart. Is this possible in ggplot2 or do I have to perform statistics first?

I hope my question is clear, thank you in advance for your help!

You can certainly easily compare the boxplots in ggplot (just add group = Exposure in your aesthetic), but to calculate statistics (e.g. means, t-test p value of difference) on the differences I would do it outside ggplot first and put it in a separate dataframe before plotting. The datanovia website has a lot of excellent example of running and plotting stats in R.

Thank you for your reply! This would compare the mean of Exposure 1 to the mean of Exposure 2, if I am correct. This is not the same as comparing both the exposures for each individual apart, which I want to know. For Fish$ID "12" compare Exposure 1 to Exposure 2, for Fish$IS "13" compare Exposure 1 to Exposure 2 etc. Or is this the same as ANOVA?

ANOVA is for comparing the differences in mean between groups. There are different ways to define the "groups" and this is why there are different kinds of ANOVA.

Data is not normally distibuted, therefor I can't preform an ANOVA. What to do know?

If each Fish is tested twice, and you have a single non-Normal response at each test, then wouldn't a Paired Samples Wilcoxon Test be most suitable and simpler? This is a non-parametric version of a paired t-test.

Would you want to visualise something like this:

The image is taken from the linked article here: