Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generation of R files to build? #197

Open
zkamvar opened this issue Jan 2, 2017 · 4 comments
Open

Add generation of R files to build? #197

zkamvar opened this issue Jan 2, 2017 · 4 comments

Comments

@zkamvar
Copy link
Contributor

zkamvar commented Jan 2, 2017

Something useful for teaching might be to have the R scripts available for people to download from the website by replacing "html" with "R". This is easily achieved with the command knitr::purl('$<', documentation = 2).

I would issue a pull request, but I'm not terribly literate in Make. What do you think, @hlapp?

@hlapp
Copy link
Member

hlapp commented Jan 3, 2017

Sounds like a good idea. Can you elaborate how you envision this to work? For example, can you show the commands (or steps) someone would type (into R? the command line?) if this were enabled?

@zkamvar
Copy link
Contributor Author

zkamvar commented Jan 3, 2017

So, in the makefile, we would have a rule that converts Rmd to R using knitr::purl(). These R files will be placed in the same directory as the html files so that if one wanted to download the R file, they could simply change the URL from http://popgen.nescent.org/LMM-Genetic-Diversity.html
to http://popgen.nescent.org/LMM-Genetic-Diversity.R.

It is currently possible to obtain an R script from the original Rmd with the following, but it might be a bit cumbersome for novice users.

vig <- "LMM-Genetic-Diversity.Rmd"
head <- "https://raw.githubusercontent.com/NESCent/popgenInfo/master/use/"
knitr::purl(paste0(head, vig), documentation = 2)

@hlapp
Copy link
Member

hlapp commented Jan 24, 2017

I looked into this. I think the main challenge here would be to implement this such that only those .Rmd documents get their scripts extract to an R script for which using them as an R script (or a template for one) would be intended.

It seems most of the documents for which this wouldn't be the case are already recognizable as plain Markdown (.md) and not Rmarkdown (.Rmd) documents. However, there seem to be a few more which are really only meant to be rendered to HTML.

We could just live with their corresponding .R scripts lying around on the website with no actual purpose (and nothing linking to them). It does feel a little unsatisfying, though, so I'm wondering whether all the .Rmd files we have that aren't vignettes really do have actively executed code during execution. Or maybe there's another rule or pattern by which we can pinpoint what should have its R code extracted? Such as being in the use/ directory?

@zkamvar
Copy link
Contributor Author

zkamvar commented Jan 25, 2017

Such as being in the use/ directory?

I think setting the rule for all .Rmd documents in the use/ and develop/ directories would be a good rule for this. I'm not very well versed in Make, so I'm not quite sure how it would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants