To calculate the height at $x$ of the graph of the t-Distribution function (centered at 0) with $df$ degrees of freedom,
R: use the function
dt(x,df)
Excel: use the function
T.DIST(x, df, FALSE)The last argument for this function, when $FALSE$, indicates that the height of the function should be returned, instead of an area under the curve.
To calculate the area to the left of some $x$ and under a curve corresponding to a $t$-distribution with $df$ degrees of freedom,
R: use the function
pt(x,df)
As an example, suppose a two-tailed hypothesis test for a mean results in a test statistic of $t=2.1$. Assuming this test statistic is tied to a $t$-distribution with 15 degrees of freedom, we can find the $p$-value for the test with the following:
> 2*pt(-2.1,df=15) [1] 0.05305526
Excel: use the function
T.DIST(x, df, TRUE)
The last argument for this function, when $TRUE$, indicates the probability returned should be an area under the curve and not a height of the function's graph.
To find the cut-off $x$-value for which a random variable following a $t$-distribution with $df$ degrees of freedom will produce an outcome less than $x$ with some given probability of $p$ (or, said another way, to find the $x$ value where there is an area of $p$ to the left of $x$ and under the related $t$-distribution curve) ...
R: use the function
qt(p,df)
As an example, to find the critical value for a right tailed $t$-test at the $0.05$ significance level, where the related distribution has $13$ degrees of freedom, one could use the following:
> qt(0.95,df=13) [1] 1.770933
Excel: use the function
T.INV(p,df)
To generate $n$ values randomly selected from a $t$-distribution with $df$ degrees of freedom,
R: use the function
rt(n,df)
Excel: copy the formula below to $n$ cells
T.INV(RAND(),df)