Knitr not displaying graph when out.width or out.height set
Instead of using knitr::knit()
it is easier to use rmarkdown::render()
. You can either call it directly
Rscript -e 'rmarkdown::render("file.Rmd")'
or indirectly using an example script from the littler
package
render.r file.Rmd
on the command line.
Dynamic height and width for knitr plots
You can for example define the width in another chunk, then use it
```{r,echo=FALSE}
x <- data.frame(x=factor(letters[1:3]),y=rnorm(3))
len = length(unique(x$x))
```
```{r fig.width=len, fig.height=6}
plot(cars)
```
Related Topics
How to Manually Change the Key Labels in a Legend in Ggplot2
Passing Parameters to R Markdown
Finding Where Two Linear Fits Intersect in R
Element-Wise Concatenation of String Vectors
All Possible Combinations of a Set That Sum to a Target Value
Use Rollapply and Zoo to Calculate Rolling Average of a Column of Variables
Get the Event Which Is Fired in Shiny
Identify Consecutively Overlapping Segments in R
Different Axis Limits Per Facet in Ggplot2
Count the Number of Non-Zero Elements of Each Column
How to Use a Graphic Imported with Grimport as Axis Tick Labels in Ggplot2 (Using Grid Functions)
Add an Image to a Table-Like Output in R
Number Format, Writing 1E-5 Instead of 0.00001