3. Run a one-sample t-test.

With regards to t-test, the function t.test() in R may be used. This is a rather simple function which performs both one- and two-sample t-tests (it is thus likely that we will meet that function elsewhere in bioST@TS).
Assuming that you have stored your sample data in the variable data, the command to use is t.test(data, alternative="XXX", mu = Y) where:
  • “XXX” shall be replaced by “greater” OR “less” OR “two.sided” depending of your alternative hypothesis Ha. The null hypothesis H0 states that the sample mean is NOT different from the population mean. Your alternative hypothesis Ha is one of the following:
    • the sample mean is greater than the population mean >> use “greater”
    • the sample mean is less than the population mean >> use “less”
    • the sample mean is either smaller or greater than the population mean >> use “two.sided”.
  • Y shall be replaced by the value of the population mean.


R returns several lines of text. One of them provides a p-value while the next line states the alternative hypothesis which depends on the parameter alternative=”XXX” that you have entered in the t.test(). This alternative hypothesis Ha is considered valid when the p-value is less than 0.05.



Read more about t.test() and find more options by clicking here or there or by simply typing ?t.test in the R console.