I want to embed statistics in an rMarkdown/notebook depending on whether an if test is passed.
I haven't found a question that addresses this in SO, but apologies if I've overlooked it.
Based on this link I found how to use an if statement to determine what text goes in, I can simply do:
``` {r}
this_p_value = .03
```
`r if(this_p_value<.05){"this is significant"} else {"this is not significant"}`
If I want to report the p-value I can do:
this_p_value is a significant as p= `r this_p_value`
I've got an answer that shows how you do both, but I imagine there may be a more elegant way than my posted solution (or at least a few alternatives). Apologies again if I've overlooked an SO question addressing this.