The t.test function has an argument named alternative which can be set to two.sided, less, or greater. You can read about the complete options by running
?t.test
Here is an example with some invented data.
x = rnorm(n = 100, mean = 1, sd = 0.1)
y = rnorm(n = 100, mean = 1.3, sd = 0.1)
t.test(x= x, y = y, alternative = "greater")
#>
#> Welch Two Sample t-test
#>
#> data: x and y
#> t = -22.147, df = 195.32, p-value = 1
#> alternative hypothesis: true difference in means is greater than 0
#> 95 percent confidence interval:
#> -0.3142285 Inf
#> sample estimates:
#> mean of x mean of y
#> 1.017068 1.309476
t.test(x= x, y = y, alternative = "less")
#>
#> Welch Two Sample t-test
#>
#> data: x and y
#> t = -22.147, df = 195.32, p-value < 2.2e-16
#> alternative hypothesis: true difference in means is less than 0
#> 95 percent confidence interval:
#> -Inf -0.2705878
#> sample estimates:
#> mean of x mean of y
#> 1.017068 1.309476
Created on 2020-08-20 by the reprex package (v0.3.0)