Open kcudding opened 2 years ago
rm(list=ls()) was added because of unresolved library conflicts. knitr options should not be set here tho.
So this gives an error now (trying to just quote code but not run it, maybe there's a better way?)
```{r treetext, eval=FALSE, echo=TRUE}
The average tree height was `r avge_height` m
I can't see what's changed lately to change the behaviour.
Options for inline code also given here. But I bet the default does not pass accessibility. https://rviews.rstudio.com/2017/12/04/how-to-show-r-inline-code-blocks-in-r-markdown/
this is showing fine for me. I'll got thru and reset your code chunks.
oh watis, it exists in multiple locations. What are you trying to show with this
{r, eval=FALSE, echo=TRUE}
The average tree height was r avge_height
m
this is not an r command, so it is parsing as an error.
Want it to print:
The average tree height was `r avge_height` m
(can be highlighted like here). i.e. the code you would type in to automatically produce the text: The average tree height was 10.1 m
Kind of a crucial learning point (that got messed up last summer when the student was confused reading it)!
I'm going back a few commits on Basics/. It wasn't actually correct on Friday (trying a couple of random commits).
yes... so this The average tree height was r knitr::inline_expr("avge_height")
produces the code... but is not echoing the back ticks like it is supposed to (not even when double backticked The average tree height was `r knitr::inline_expr("avge_height")`
, as it is suggested it will do for straight rmarkdown
Don't quite understand that. Can't get the backticks echoed.
The average tree height was `r knitr::inline_expr(" avge_height")`
gives
Got it, the correct backticking is TRIPLE, SPACE, SINGLEr knitr::inline_expr("avge_height")SINGLE SPACE TRIPLE
What's really confusing is
```{r treetext, eval=FALSE, echo=TRUE}
The average tree height was `r avge_height` m
renders fine to
![image](https://user-images.githubusercontent.com/6977190/156050681-b23483b4-5741-4208-96a6-f15956eb37d0.png)
but gives an error
Output created: docs/index.html [1] ["C:/....." Warning message: In eng_r(options) : Failed to tidy R code in chunk 'treetext'. Reason: Error in parse(text = lines, keep.source = TRUE) :
I'll push it up, and you can decide which you want.
These were giving real errors but easily fixed:
The average tree height was 10.1 m.
So are you going to push any changes, or want me to fix them all. I've added in echo=TRUE
everywhere.
I've also named all my chunks, to make debugging way easier. Should have done this ages ago.
It's just an example on that first bit.
I never had any real errors on compile?
I had Warnings that looked like Errors, but rendering still worked. Not sure what you had.
Thanks for your push. Looks like
knitr::opts_chunk$set(comment = "")
is defined anyway in index.Rmd. I've managed to keep that code as not inline, and I've done echo=TRUE everywhere. Thanks.
Just can't quite get this working at the end, want to include a single backtick before the r:
Had an un-needed backtick at the end (which kind of cancelled out the one I wanted to show). Okay, just rechecking then I'll push in a bit.
Should all be fixed in above commit (to module-2-rmarkdown), plus two associated ones.
Note that the labelling of the chunks will change the later names of png files, such as docs/_main_files/figure-html/unnamed-chunk-34-1.png
etc.
And you might have to git add
the new .png files to get them included in the built .html.
(Need to get some lunch).
So I think the input text may have been missing for a while, just hadn't noticed (too busy doing alt text etc.).
I have some ideas for better setting up the workflow (for any future such books) - will make an Issue to note them. Mainly that the full output files shouldn't be pushed each time.
Don't forget to do your 2021->2022 quick fudge in the .Rmd also :o
Do note that the "failed to tidy" errors mean that I cannot guarantee that these "faux" code chunks do not scroll off the page.
Okay. I think they should be good. That was all brutal, and wasn't actually that much to fix in the end. Those fake errors threw me off big time. Thanks for your help. Probably good to close?
Well, I'm not happy with this solution since it does throw all these warnings, and also I have to manually check chunk lengths as a result. So leave this open till we find a better answer.
Basically, you want this text formatted as tho it were an input code chunk. I can probably make boxes for them with enough css
Do the warnings get shown in the .html? I can't see them on the rendered version you pushed. Okay to live with them? Longest faux code is
`r ifelse(max(y)>400, paste("greater than"), paste("less than"))
which is just over 60 characters (but shorter than other real code). If you want it shorter I can take the 'than' out.
Realised this should ideally have a pesky ` at the end. I had to take it out to get the first one to render. Ugh. Can live with that, and it's all in the .Rmd exercise file I think.
You mentioned boxes, but then they'd look like output, which will be confusing as they're code examples. I'm in meetings the next few days but not the whole time, so can keep an eye on here (and will be on Slack).
"box" meaning rectangular object which may or may not have a border. I assure you, we can make it look the same as an input code box...altho it is NOT input code, and so I'm not crazy about this representation anyway. We need formatting that clearly distinguishes an input code chunk from an inline text/code combo.
I don't want to leave this way since there is a long line of warnings which I will then have to check each time we add new content.
At any rate, no time to address until next month at earliest.
Something (maybe this fix) has removed the input text from the R Markdown module. I saw this at the start of
classifymod.Rmd
which is a bad idea (therm(list=ls())
in particular) as it will reset the knitr options from what they are at the start.Originally posted by @andrew-edwards in https://github.com/quantitative-biology/Basics/issues/20#issuecomment-1054504050