# How to return a logical value for a t test based on 0.05 level of significance in R?

To return a logical value for a t test based on 0.05 level of significance in R, we can follow the below steps −

• First of all, create a data frame with one column.
• Apply t.test function with ifelse to return logical value based on 0.05 level of significance.

## Example1

Create the data frame

Let's create a data frame as shown below −

Live Demo

x<-rnorm(20)
df1<-data.frame(x)
df1

On executing, the above script generates the below output(this output will vary on your system due to randomization) −

      x
1 0.44038858
2 1.08938356
3 -0.23627885
4 0.73953751
5 -0.55476732
6 0.97726848
7 0.25612436
8 -1.89827676
9 0.50333232
10 0.55482166
11 1.83279952
12 0.93609228
13 0.35048901
14 0.05136088
15 -0.89102106
16 1.06392349
17 -0.15777431
18 0.45506977
19 1.43752763
20 1.27393923

## Apply t.test to get the logical return

Using t.test with ifelse to return logical output based on significance level 0.05 for less than alternative −

Live Demo

x<-rnorm(20)
df1<-data.frame(x)

### Output

[1] "No"