'Rmarkdown displaying results even when I use results = 'hide'
I have a weird situation - and I apologize in advance, but this issue doesn't lend itself to a reproducible example. Here is the situation
Here is the skeleton of the problem
Chunk 1
Chunk 2
...
Chunk N-1
Then I have a chunk which is basically of the form:
{r chunkname, results = 'asis'}
f <- function(x){
y <- some computation on x
return(y)
}
T1 <- f(A)
T2 <- f(B)
According to the structure, nothing should get displayed, but when I knit the Rmarkdown file, both T1 and T2 appear. This is true even if I use results = 'hide'.
Now the weirder part. If I put the offending chunk in an Rmarkdown file by itself, it behaves as it should, and does not display T1 and T2.
The preceding chunks (Chunk1 - ChunkN-1) all run exactly as expected - no weird behaviors.
Last clue - not sure if it matters. The function in the offending chunk involves generating a table with gt.
I'm sorry - I realize there isn't a lot to go on here, but this is a chunk in the middle of several thousand lines of code - all of which run fine. And, when the offending code is on its own, it behaves.
Solution 1:[1]
I believe I have found an aswer to this problem. I left something seemingly innocuous out of my post.
The original code looked basically like:
{r chunkname, results = 'asis'}
f <- function(x){
y <- some computation on x
return(y)
}
T1 <- f(A)
T2 <- f(B)
save(T1)
save(T2)
Note that in my original post, I failed to include the "save(T1)" part. Well, it turned out that was the problem. If, instead of save(T1) I substitute temp <- save(T1), the issue disappears.
I don't understand why a save was causing something to be displayed. I also don't really understand what "assigning" the save action to the variable temp even means. But - it suppresses the output of the results to the kintted file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MikeS |
