Where's my function? (General R / RStudio question)

Really two questions here. When I create a project I often have many function and create multiple source files (i.e. .r files) to logically organize the project. Is there a better practice? When an error is thrown it might say something like error in myFunction. Let's say I have several source files and forgot which one contains myFunction. Is there a quick way to tell which source file (e.g. sourceCode.r) contains myFunction? Thanks.

1 Like

The structure of a project file set can vary according to the purposes of a project, but best practices suggests keeping .R files in a project subdirectory called R/. If you want to find a function within a file and don't know where it is, use the Go to file/function search bar near the top of the RStudio IDE. Start typing the function name and once the function is identified you can hit enter or tab to navigate to the file and even the line in the file where that function definition begins.

Hope this is helpful.

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.