Show decision tree plots in Plots pane, instead of in editor window

why does the decision tree/plot sometimes show in the editor window under the code (left side), and sometimes it shows up in the "Plots" section (right side)

How can you get it to show up in the "Plots" section, so that it can exported?

This might happen if you are executing code inside an R Markdown document, where it's possible to have the results of running code chunks displayed "inline" (right below the chunk, in the Source pane).

If you're executing code in a plain .R script file, then plots will appear in the Plots pane. If you want to see plots from your R Markdown document appear in the Plots pane, you can temporarily turn off inline results:


Look for the gear menu (next to the Knit button), and change from "Chunk Output Inline" to "Chunk Output in Console".