I am just starting to work with R, and this has probably been answered previously. In other languages like Javascript and Python, one can split their code in multiple files and then export functions from one and import them in another, within your project.
Example in Python is
To export from one file:
def CountWords(words):
if words is not None:
NumberOfWords = [Eachword.count(' ') + 1 for Eachword in words]
return NumberOfWords
To import in another file:
from wordcounter import CountWords
# use the CountWords function here
What is the equivalent of this in R?