Started using packrat for a couple of packages.
Sad to say that now the handy RStudio "find in files" facility
is far less useful,
because the result is often overwhelmed with hits from file in the packrat folder.
Silly me, there is a "Search in:" box in the "Find in files" window.
Maybe that was added to RStudio after I asked this question (or maybe not).
Temporally, I think this is another way to do it.
And Hi @kevinushey, do you know how to use this feature by r function, like some functions in rstudioapi package. If there is such a function, I think we can custom a function to do this @RogerDay want.
There isn't an API function for Find in Files -- you could consider requesting this with a feature request.
No need for me to take further action, as I noted above, the 'fix' was just to open my eyes a little wider!
(Maybe somebody else will need to search from the package root, for example to search both R and inst in the same search, but my purposes are satisfied using the "Search in..." feature.)