Plotting t-statistic in R

How can I plot the t-statistic of the results shown below in R?

You can access the t statistic through the statistic element of the object returned by the t.test function. Is that what you want to do?

x <- rnorm(434, 207, 50)

FIT <- t.test(x, mu = 208.5)
#>  One Sample t-test
#> data:  x
#> t = -2.9546, df = 433, p-value = 0.003301
#> alternative hypothesis: true mean is not equal to 208.5
#> 95 percent confidence interval:
#>  197.1966 206.2275
#> sample estimates:
#> mean of x 
#>   201.712

#>         t 
#> -2.954601

Created on 2019-11-25 by the reprex package (v0.3.0.9000)

Hi, and welcome!

A reproducible example, called a reprex will attract more answers. @FJCC provides an example. Screen shots are no substitute.

In this case, you need to go beyond just the default print of t.test and explain what type of plot you're looking to produce. A single point, the test statistic, isn't very informative, although it's certainly possible to plot a point on the x or y axes with its value.

There is a plot method for the two-sample t test. See the examples in the help page:


## Classical example: Student's sleep data
plot(extra ~ group, data = sleep)

Created on 2019-11-25 by the reprex package (v0.3.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.