

The following output is generated by RStudio in the area, which includes: (a) the R code that you have just run (i.e., in the red rectangle) and (b) the results for the independent-samples t-test (i.e., in the blue rectangle): Press the Enter/Return key on your keyboard to run the independent-samples t-test. Therefore, the R code above will run an independent-samples t-test assuming that the assumption of homogeneity of variances has been met based on the istt data set that is being used to determine if there is a mean difference between the two groups of our independent variable, group (i.e., the "control" and "exercise" groups of our exercise trial) in terms of the scores of our dependent variable, cholesterol (i.e., the cholesterol of participants, measured in mmol/L). T.test (cholesterol ~ group, var.equal=TRUE, data = istt) Using the instructions above, we entered the following R code into the RStudio Console (i.e., under the tab): Note: If you are unsure what name you gave your dataframe, see the important note in Step 3 of the section: Import your data from Microsoft Excel into RStudio. However, the word dataframe should be replaced with the name of your dataframe (e.g., istt in our example). The R code data = should be entered exactly as shown. More specifically, this is telling R where to look for the data of your dependent and independent variables. Run an independent-samples t-test on the data that was imported into the dataframe.

Note: This code is only relevant if your data has met this assumption.Īgain, notice that a comma ( ,) is entered at the end of this R code. Enter this R code exactly as shown without making any changes. This option also assumes that the data has met the assumption of homogeneity of variances, as discussed earlier. Notice that a tilde ( ~) is entered between the name of the dependent and independent variable.Īlso notice that a comma ( ,) is entered at the end of this R code. In other words, replace the words dv and iv with the names of your dependent and independent variables respectively, exactly as you spelt them in Step One in Excel earlier in this guide. Run a t-test using the dv (i.e., dependent variable) and iv (i.e., independent variable) included between the brackets. Which t-test is run will depend on what variables and options are entered between the brackets ( ). Note: The t.test () function can be used to run several t-tests, including the one-sample t-test, independent-samples t-test (as demonstrated in this guide), Welch t-test, and paired-samples t-test. Run a t-test based on the variables and information/options included between the brackets ( ). More specifically, this R code has the following meaning: t.test ( ) T.test (dv ~ iv, var.equal=TRUE, data = dataframe) The code to run an independent-samples t-test using R is as follows:
USING OBS STUDIO WITH DIAMOND GC1500 HOW TO
In the three steps that follow we explain how to run an independent-samples t-test using R: The independent-samples t-test is run using R code in RStudio, which you enter into the RStudio Console (i.e., under the tab), as shown below: R and RStudio Running an independent-samples t-test using R in RStudio Therefore, start by learning how to use the t.test () function to carry out an independent-samples t-test in the next section.

On this page we show you how to: (a) carry out an independent-samples t-test using the t.test () function (b) generate useful descriptive statistics including the group means, standard deviations, sample sizes, and the mean difference. On the previous page you learnt how to set up your data using Excel, R and RStudio, based on the example we use throughout this introductory guide.

Independent-samples t-test using R, Excel and RStudio (page 3)
