Help with loops in functions and dataframes

you could start by reading about ttests here: https://statistics.berkeley.edu/computing/r-t-tests
and how to produce examples of your data here :FAQ: How to do a minimal reproducible example ( reprex ) for beginners