'Difference between `devtools::install` and build manually considering `system.file`

I'm quite a newbie in R, however, I thought that devtools::install and building a package manually in RStudio do the same thing. I've never noticed any differences.

However, today I wanted to access some files in my package via system.file("extdata", package="MyPackage") and always got "" as return value. I double checked it that the folder MyPackage exist in ~\R\R-4.1.3\library\.

Only after running devtools::install() inside my project, system.file("extdata", package="MyPackage") gave me the absolute path to the folder as intended.

Can you explain this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source