Fix/quarto mostly typos (#1505)
* probably a typo * probably a typo * no Insert menu in Rstudio * a typo * better to stick to percentage notation * not suffix but prefix * redundant, perhaps forgot to delete * !r erros * a typo * I don't know why Rstudio automatically changes lines. I manually removed those changes. * Update quarto.qmd * Update quarto.qmd --------- Co-authored-by: Mine Cetinkaya-Rundel <cetinkaya.mine@gmail.com>
This commit is contained in:
parent
476f5c01b6
commit
1bac6a5025
23
quarto.qmd
23
quarto.qmd
|
@ -429,7 +429,7 @@ comma(.12358124331)
|
|||
|
||||
The figures in a Quarto document can be embedded (e.g., a PNG or JPEG file) or generated as a result of a code chunk.
|
||||
|
||||
To embed an image from an external file, you can use the Insert menu in RStudio and select Figure / Image.
|
||||
To embed an image from an external file, you can use the Insert menu in the Visual Editor in RStudio and select Figure / Image.
|
||||
This will pop open a menu where you can browse to the image you want to insert as well as add alternative text or caption to it and adjust its size.
|
||||
In the visual editor you can also simply paste an image from your clipboard into your document and RStudio will place a copy of that image in your project folder.
|
||||
|
||||
|
@ -448,7 +448,7 @@ We recommend three of the five options:
|
|||
Then in individual chunks, only adjust `fig-asp`.
|
||||
|
||||
- Control the output size with `out-width` and set it to a percentage of the line width.
|
||||
We suggest to `out-width: "70%"` and `fig-align: center`.
|
||||
We suggest `out-width: "70%"` and `fig-align: center`.
|
||||
That gives plots room to breathe, without taking up too much space.
|
||||
|
||||
- To put multiple plots in a single row, set the `layout-ncol` to 2 for two plots, 3 for three plots, etc.
|
||||
|
@ -490,7 +490,7 @@ plot
|
|||
```
|
||||
|
||||
If you want to make sure the font size is consistent across all your figures, whenever you set `out-width`, you'll also need to adjust `fig-width` to maintain the same ratio with your default `out-width`.
|
||||
For example, if your default `fig-width` is 6 and `out-width` is 0.7, when you set `out-width: "50%"` you'll need to set `fig-width` to 4.3 (6 \* 0.5 / 0.7).
|
||||
For example, if your default `fig-width` is 6 and `out-width` is "70%", when you set `out-width: "50%"` you'll need to set `fig-width` to 4.3 (6 \* 0.5 / 0.7).
|
||||
|
||||
Figure sizing and scaling is an art and science and getting things right can require an iterative trial-and-error approach.
|
||||
You can learn more about figure sizing in the [taking control of plot scaling blog post](https://www.tidyverse.org/blog/2020/08/taking-control-of-plot-scaling/).
|
||||
|
@ -510,12 +510,12 @@ In that case, set `fig-format: "png"` to force the use of PNGs.
|
|||
They are slightly lower quality, but will be much more compact.
|
||||
|
||||
It's a good idea to name code chunks that produce figures, even if you don't routinely label other chunks.
|
||||
The chunk label is used to generate the file name of the graphic on disk, so naming your chunks makes it much easier to pick out plots and reuse in other circumstances (i.e. if you want to quickly drop a single plot into an email).
|
||||
The chunk label is used to generate the file name of the graphic on disk, so naming your chunks makes it much easier to pick out plots and reuse in other circumstances (e.g., if you want to quickly drop a single plot into an email).
|
||||
|
||||
### Exercises
|
||||
|
||||
1. Open `diamond-sizes.qmd` in the visual editor, find an image of a diamond, copy it, and paste it into the document. Double click on the image and add a caption. Resize the image and render your document. Observe how the image is saved in your current working directory.
|
||||
2. Edit the label of the code chunk in `diamond-sizes.qmd` that generates a plot to start with the suffix `fig-` and add a caption to the figure with the chunk option `fig-cap`. Then, edit the text above the code chunk to add a cross-reference to the figure with Insert \> Cross Reference.
|
||||
2. Edit the label of the code chunk in `diamond-sizes.qmd` that generates a plot to start with the prefix `fig-` and add a caption to the figure with the chunk option `fig-cap`. Then, edit the text above the code chunk to add a cross-reference to the figure with Insert \> Cross Reference.
|
||||
3. Change the size of the figure with the following chunk options, one at a time, render your document, and describe how the figure changes.
|
||||
a. `fig-width: 10`
|
||||
|
||||
|
@ -555,7 +555,7 @@ Each provides a set of tools for returning formatted tables from R code.
|
|||
|
||||
1. Open `diamond-sizes.qmd` in the visual editor, insert a code chunk, and add a table with `knitr::kable()` that shows the first 5 rows of the `diamonds` data frame.
|
||||
2. Display the same table with `gt::gt()` instead.
|
||||
3. Add a chunk label that starts with the suffix `tbl-` and add a caption to the table with the chunk option `tbl-cap`. Then, edit the text above the code chunk to add a cross-reference to the table with Insert \> Cross Reference.
|
||||
3. Add a chunk label that starts with the prefix `tbl-` and add a caption to the table with the chunk option `tbl-cap`. Then, edit the text above the code chunk to add a cross-reference to the table with Insert \> Cross Reference.
|
||||
|
||||
## Caching {#sec-caching}
|
||||
|
||||
|
@ -677,9 +677,6 @@ If you publish the HTML file on a hosting platform (e.g., QuartoPub, <https://qu
|
|||
However, if you want to email the report to a colleague, you might prefer to have a single, self-contained, HTML document that embeds all of its dependencies.
|
||||
You can do this by specifying the `embed-resources` option:
|
||||
|
||||
By default these dependencies are placed in a `_files` directory alongside your document.
|
||||
For example, if you render `report.qmd` to HTML:
|
||||
|
||||
``` yaml
|
||||
format:
|
||||
html:
|
||||
|
@ -708,13 +705,13 @@ cat(readr::read_file("quarto/fuel-economy.qmd"))
|
|||
As you can see, parameters are available within the code chunks as a read-only list named `params`.
|
||||
|
||||
You can write atomic vectors directly into the YAML header.
|
||||
You can also run arbitrary R expressions by prefacing the parameter value with `!r`.
|
||||
You can also run arbitrary R expressions by prefacing the parameter value with `!expr`.
|
||||
This is a good way to specify date/time parameters.
|
||||
|
||||
``` yaml
|
||||
params:
|
||||
start: !r lubridate::ymd("2015-01-01")
|
||||
snapshot: !r lubridate::ymd_hms("2015-01-01 12:30:00")
|
||||
start: !expr lubridate::ymd("2015-01-01")
|
||||
snapshot: !expr lubridate::ymd_hms("2015-01-01 12:30:00")
|
||||
```
|
||||
|
||||
### Bibliographies and Citations
|
||||
|
@ -834,7 +831,7 @@ We've drawn on our own experiences and Colin Purrington's advice on lab notebook
|
|||
|
||||
## Summary
|
||||
|
||||
In this chapter introduced you to Quarto for authoring and publishing reproducible computational documents that include your code and your prose in one place.
|
||||
In this chapter we introduced you to Quarto for authoring and publishing reproducible computational documents that include your code and your prose in one place.
|
||||
You've learned about writing Quarto documents in RStudio with the visual or the source editor, how code chunks work and how to customize options for them, how to include figures and tables in your Quarto documents, and options for caching for computations.
|
||||
Additionally, you've learned about adjusting YAML header options for creating self-contained or parametrized documents as well as including citations and bibliography.
|
||||
We have also given you some troubleshooting and workflow tips.
|
||||
|
|
Loading…
Reference in New Issue