There is a specific structure that you must follow if you want to develop a package in R. This blog post shows a very simple skeleton package with a single R function and explains what you need to include to make things official. Most writing on this topic is very dense, but this is very easy to follow.
Chris Evans. Making the CECPfuns package: my own usable package. R SAFAQ blog 2021-02-09. Available in html format.