I'm relatively new to RMarkdown. I created a chunk that runs my R script that has a gt table. It runs fine and renders perfectly, but when I try to source it back to a script instead of embedding it into the RMarkdown file, all I get is the YAML title. Any ideas what's going on?
Hi @scottyd22 yes it does. If the whole script is embedded in the R Markdown file, it renders fine. It's only when I try to source to a script that it doesn't show up. There's also no errors that show up.
@JohnN8797 I believe that when you source() you need to use explicit print() calls on the objects you wish to show up. See the details section in this documention. Trying placing the object that you wish to print in a print() function call in the script that you are sourcing (if it isn't already in one).
Is it in the source code that I put the gt table call in a print function?
So at the end of the gt script I type out the name of the table to have it rendered. Instead of that, do I put it within the print function? E.g., print (nameofgttable). Or is it in the RMarkdown file?
Yes, so in your Rmarkdown down document you'll just have source("your_r_script") and in your sourced script you'll have print(table_object) I assume near the end.