Allow "console display" when sending code from a chunk #931 If you still don't use ggplot2 or, as I do, have to use the old and finicky plot() function, read on to discover a trick I use to display a legend outside the plotting area. fig.width = 6, fig.height = 6 * 7/9. There are ways to change this line height but that's a useful number to keep in mind. As in other Rmd documents, you can use the fig.cap chunk option to provide a figure caption, and adjust figure . The kableExtra package builds on the kable output from the knitr package.As author Hao Zhu puts it: The goal of kableExtra is to help you build common complex tables and manipulate table styles.It imports the pipe %>% symbol from magrittr and verbalize all the functions, so basically you can add "layers" to a kable output in a way that is similar with ggplot2 and plotly. Command + Option + I. 9.5.1 Captions for figures. Problem with Plots or Graphics Device in the RStudio IDE Saving Plots in R | Department of Statistics Voila! Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. You will not actually see the plot - the commands are being saved to a file instead . The R Markdown interface # LinkedIn Learning 3.2. In this R tutorial you'll learn how to draw line graphs. In this post we'll get into more details around how to control code output using chunk options. After some testing, a width/height ratio of 9:7 seems appropriate in this case. R Markdown Tips, Tricks, and Shortcuts - R-bloggers A report. 5.4 Control the size of plots/images. Once we have all the R packages we need loaded, we can then setup our plot.ly R API connection: Paste the following below the previous r code chunk (i.e. Being able to scroll through the R Markdown file and see not only the code but also the output is nice. The par() function is the main function for setting graphical parameters in base R and the mar = argument sets the size of the margins that surround the plot. Output your document in the format specified in your YAML header with Command + Shift + K on a Mac, or Ctrl + Shift + K on Linux and Windows. This handbook strives to: Serve as a quick R code reference manual. Note that the numbers default to inches as unit: {r fig1, fig.height = 3, fig.width = 5}. 3.3. Subsetting datasets in R include select and exclude variables or observations. R version 3.6.3 (2020-02-29) Platform: x86_64-apple-darwin15.6. For example, echo = -2 means to exclude the second expression of the source code in the output. Plot(x, y): plot y (y-percentage) to a new line. There are a few shortcuts for this option: fig.keep = "first" will only keep the first plot, fig.keep . ```{r echo=FALSE} read_chunk('example.R') ``` ```{r variablesXY} ``` ```{r plotXY} ``` In either case, the output would look like this: Advanced tips: Run and show external code but leave off the comments. To show an arbitrary text in your chart you can use texttemplate, which is a template string used for rendering the information, and will override textinfo.This template string can include variables in %{variable} format, numbers in d3-format's syntax, and date in d3-time-fomrat's syntax.