Great question! There are several places where you can set environment variables, especially when running R on a server. This allows you to set environment variables for specific projects, users, or all users on a server.
This article provides a great explanation and links to more detailed documentation, but here's a quick visual summary:
You can also read more about the differences between the various startup files here.