In this article, we will show you how to use the **pt() function in R.** The pt() function helps you calculate the value of the cdf (cumulative distribution function) of the Student t distribution. Let’s follow this article to learn more about it with the explanation and examples below.

**Pt() function in R**

**What does pt() do in R?**

The pt() function helps calculate the value of the cdf (cumulative distribution function) of the Student t distribution by the given value and the degree of freedom.

**Syntax**:

`pt(q, df, lower.tail = TRUE, log.p = FALSE)`

**Parameters**:

**q:**The vector of the quantiles**df:**The degree of freedom.**lower.tail:**The default is TRUE. If TRUE, the function calculates the probability when the value is less than or equal to the given value. Otherwise, the function will calculate the probability when the value is greater than the given value.**log.p:**The default is FALSE. The result will be shown as log(p) or not.

After learning the usage and syntax of the pt() function, you will learn how to use it in the next title below.

**How to use the pt(**)** function in R**?

**Calculate the probability when the value is less than or equal to the given value**

You can calculate the probability when the value is less than or equal to the given value by the pt() function.

Look at the example below.

# calculate the probability when the value is less than or equal to 0.25 with the degree of freedom is 2. pt(0.25,2)

**Output**

`[1] 0.5870388`

**Calculate the probability when the value is greater than the given value**

You also can calculate the probability when the value is greater than the given value by the pt() function.

Look at the example below.

# calculate the probability when the value is greater than 0.25 with the degree of freedom is 2. 1 - pt(0.25,2)

**Output**

`[1] 0.4129612`

You can also do this work by setting the parameter lower.tail = FALSE.

Look at the example below.

pt(0.25,2,lower.tail = FALSE)

**Output**

`[1] 0.4129612`

**Summary**

You have learned about the **pt() function in R**. The pt() function is one of the functions that can help you work with the Student t distribution. By this function, you can calculate the value of the cdf (cumulative distribution function) of the Student t distribution. We hope this tutorial is helpful to you. Thanks!

**Maybe you are interested**:

- print() Function In R Programming Language
- Head function in R: How to use head() in R
- length() function in R: How To Use The Length Function In R

My name is Thomas Valen. As a software developer, I am well-versed in programming languages. Don’t worry if you’re having trouble with the C, C++, Java, Python, JavaScript, or R programming languages. I’m here to assist you!

**Name of the university:** PTIT

**Major**: IT

**Programming Languages**: C, C++, Java, Python, JavaScript, R