T-test on a graph

Just wondering if anyone could help:
How do I code a t-test? Also how do I isolate two variables in it to compare?

What does isolating variables mean ?
Have you tried "R t-test" in google ?

Are you looking for stats::t.test()?

There's several ways but here's a vignette using the infer package which might help: Tidy t-Tests with infer • infer

isn't infer::t_test a wrapper for stats::t.test?

Yes - some folks find the syntax easier.