csgillespie / efficientR

Efficient R programming: a book
https://csgillespie.github.io/efficientR/
Other
721 stars 375 forks source link

Following example in chapter 7 not possible: source file `monopoly.R` not found #315

Open selinaZitrone opened 1 year ago

selinaZitrone commented 1 year ago

First of all: Really great and helpful book. Thanks a lot for writing and sharing!

Summary of the issue

I Could not run the monopoly simulation example for code profiling in chapter 7 with the code given in the book. The problem is that the profile is produced but the source file monopoly.R is not available, so Figure 7.2 could not be reproduced. I solved the issue by cloning and building the package locally, but probably there is a better solution?

Details of what I tried

First, I installed the package from source like described in the text:

devtools::install_github("csgillespie/efficient",
                         args = "--with-keep.source")

This installed the package but got me a warning:

grafik

When I did the profiling as suggested in the book, it works but the source file monopoly.R is not available. So I get the profile but I cannot reproduce the screenshot Figure 7.2 showing the profile per line of code.

I thought this might have something to do with the warning I got, so instead I tried:

remotes::install_github("csgillespie/efficient",
                         args = "--with-keep.source")

This installed the package without the warning message but the problem was still that the profile did not show the source file monopoly.R

What I tried next:

This worked and the profile shows me the actual source code of monopoly.R like shown in Figure 7.2

Not sure if I missed anything or if this is a problem that others also ran into.

Robinlovelace commented 1 year ago

Thanks @selinaZitrone. Any ideas @csgillespie ?