How to Perform Paired
    Samples t-test in R

    Looking for a Paired Samples t Test in R? Doing it yourself is always cheaper, but it can also be a lot more time-consuming. If you’re not good at R programming, you can pay someone to do your R task for you.

    What is a Paired Samples t-test?

    The T-test provides insight into whether the difference between the means of two groups is due to chance or is reliable (ie would be found again in another measurement from the same population). As opposed to a descriptive statistic, which describes the sample being measured, the t-test is an inferential statistic, which describes the sample being measured and provides a generalization for the entire population from which the sample was taken. Lastly, It is also called the dependent t-test or repeated t-test.

    The paired-sample t-test is a parametric statistic technique used when we have one group of participants and collect data from them on two occasions or under two different conditions. For example, we collect data about stress or anxiety levels before and after exams. Therefore, we have one continuous dependent variable and one independent categorical variable (time one and time 2, or before and after).

    When Should a Paired Sample t-test be Used?

    Paired sample t-test is a statistical technique that is used to compare two population means in the case of two samples that are correlated. In other words, You should use a paired t-test when you have the same subjects in both conditions being compared.

    An Example Of Dependent t-tests 

    For example, Suppose that teacher wants to know whether a training program in statistics improves exam marks. Therefore, the teacher gives students an exam before the statistics training program and records marks on a scale of 1 to 5. Students take statistics classes, and the teacher gives them the exam after the training programs. Therefore, we have one dependent variable, the exam mark, and one independent variable, the training program in statistics (before, and after).

    Therefore, we test the following hypotheses:

    Null hypothesis: There is no significant difference in exam marks before and after the statistics training program.

    Alternative hypothesis: There is a significant difference in exam marks before and after the statistics training program.

    R function to Compute Dependent t-test

    The code to run a dependent sample t-test using R is as follows:

    t.test (x,  y, paired=TRUE, data = dataframe)


    x: numeric vector (pre-scores)

    y: numeric vector (post or follow-up scores)

    paired: a logical value specifying that we want to compute a paired t-test

    Running paired t test in Rstudio

    In this section, we will show you how to run the paired samples t-test using the r studio program and how to interpret the test results after we obtain the result of the test. In the first part, we present the r program code and function for the dependent t-test. Next, you will see the outputs as a result of running the r codes. In the last section, you can find the interpretation of the paired samples t-test in APA format.

    Data <- read_excel(“Data.xlsx“)
    data <- Data
    premark <- data$premark
    postmark <- data$postmark





    res <- t.test(premark, postmark, paired = TRUE)

    > mean(premark)
    ## [1] 3.464646
    > sd(premark)
    ## [1] 1.357617
    > mean(postmark)
    ## [1] 3.626263
    > sd(postmark)
    ## [1] 1.035944
    > res <- t.test(premark, postmark, paired = TRUE)
    > res
    ##  Paired t-test
    ## data:  premark and postmark
    ## t = -0.84919, df = 98, p-value = 0.3978
    ## alternative hypothesis: true mean difference is not equal to 0
    ## 95 percent confidence interval:
    ##  -0.5392953  0.2160629
    ## sample estimates:
    ## mean difference 
    ##      -0.1616162

    Reporting Matched Paired t-test in R

    Paired sample t-test was conducted to determine whether there is a difference in exam marks before and after taking a training program in statistics. The results indicate a non-significant difference in exam mark before taking training program in statistics (M = 3.46; SD = 1.36) and after taking training program in statistics (M = 3.63; SD = 1.04), t(98) = -0.85, p = 0.398. The mean difference is -0.16. The 95% confidence interval ranged from -0.54 to 0.22 and does not indicate a significant difference between the sample means. We, therefore, fail to reject the null hypothesis and conclude that there is no significant difference in exam marks before and after the statistics training program

    Are you in trouble with RStudio?


    There is a lot of statistical software out there, but R is one of the most popular. If you’re a student who needs help with R Studio, there are a few different resources you can turn to. We prepared a page for R tutorial for Beginners. All contents can guide you through Step-by-step R data analysis tutorials and you can see Basic Statistical Analysis Using the R Statistical Package.

    The second option is that you can get help from us, we give R Studio help for students with their assignments, dissertation, or research. Doing it yourself is always cheaper, but it can also be a lot more time-consuming. If you’re not the best at SPSS, then this might not be a good idea. It can take days just to figure out how to do some of the easier things in SPSS. So paying someone to do your R task will save you a ton of time and make your life a lot easier.

    The procedure of the R help service at OnlineSPSS.com is fairly simple. There are three easy-to-follow steps.

    1. Click and Get a FREE Quote
    2. Make the Payment
    3. Get the Solution

    Our purpose is to provide quick, reliable, and understandable information about Rstudio data analysis to our clients.

    Open chat
    Need Data Analysis Help ?
    How may I help you?