--- title: "Diamond sizes" date: 2022-09-12 format: html: embed-resources: true editor_options: chunk_output_type: console execute: echo: true knitr: opts_chunk: comment: "#" collapse: false fig.width: 6 fig.asp: 0.618 out.width: "70%" fig.align: center csl: apa.csl bibliography: references.bib --- ```{r} #| label: setup #| include: false library(tidyverse) smaller <- diamonds %>% filter(carat <= 2.5) fnum <- function(x) format(x, digits = 2, big.mark = ".", decimal.mark = ",") x <- 3452345 y <- 0.12358124331 ``` X equals `r x` and Y equals `r y`. X equals `r fnum(x)` and Y equals `r fnum(y)`. # Diamonds We have data about `r nrow(diamonds)` diamonds. Only `r nrow(diamonds) - nrow(smaller)` are larger than 2.5 carats. The distribution of the remainder is shown below: ```{r} #| label: plot-smaller-diamonds #| echo: false smaller %>% ggplot(aes(x = carat)) + geom_freqpoly(binwidth = 0.01) ``` ### Formatting *italic* **bold** [underline]{.underline} ~~strikeout~~ [small caps]{.smallcaps} `code` X^supescript^ X~subscript~ ### **Headings** # 1st Level Header ## 2nd Level Header ### 3rd Level Header #### 4th Level Header ##### 5th Level Header ###### 6th Level Header ## Lists - Bulleted list: Item 1 - Item 2 - Item A - Item B 1. Numbered list: Item 1 2. Item 2 1. Item 2.1 2. Item 2.2 ## Links and Images [Quarto](https://quarto.org/ "Quarto documentation") ![optional caption text](logo.jpg){fig-alt="Quarto logo and the word quarto spelled in small case letters"} ## Tables | First Header | Second Header | |:------------:|:-------------:| | Content Cell | Content Cell | | Content Cell | Content Cell | ## Code chunks ```{r} #| label: simple-addition 1 + 1 ``` ```{r} #| label: simple-multiplication #| eval: false 2 * 2 ``` Co můžeme nastavit na false (outputem se myslí konzolový output, messages jsou "nevarovná" hlášení, warnings jsou "varovná") | Option | Run code | Show code | Output | Plots | Messages | Warnings | |------------------|:--------:|:---------:|:------:|:-----:|:--------:|:--------:| | `eval: false` | X | | X | X | X | X | | `include: false` | | X | X | X | X | X | | `echo: false` | | X | | | | | | `results: hide` | | | X | | | | | `fig-show: hide` | | | | X | | | | `message: false` | | | | | X | | | `warning: false` | | | | | | X | ## Diamond carats by cut, color, and clarity ```{r} #| label: carats #| echo: false bigger <- diamonds %>% filter(carat > 2.5) p <- bigger %>% ggplot(aes(cut, carat)) + geom_boxplot() ``` ```{r} #| label: plot-1 #| echo: false #| fig-width: 2 #| out-width: '50%' p ``` ```{r} #| label: plot-2 #| echo: false #| fig-width: 2 #| out-width: '100%' p ``` ```{r} #| label: plot-3 #| echo: false #| fig-width: 10 #| out-width: '50%' p ``` ```{r} #| label: plot-4 #| echo: false #| fig-width: 10 #| out-width: '100%' p ``` ## Tables ```{r} #| label: mtcars mtcars[1:5, ] knitr::kable(mtcars[1:5, ], ) ``` [DataTable options](https://datatables.net/reference/option/) ## Caching ```{r} #| label: raw-data #| cache: true #| cache.extra: !expr file.mtime("people-10000.csv") rawdata <- readr::read_csv("people-10000.csv") glimpse(rawdata) ``` ```{r} #| label: processed-data #| cache: true #| dependson: 'raw-data' processed_data <- rawdata %>% filter(Sex == "Female") ``` ## Citace To add a citation using the visual editor, go to Insert \> Citation. Citations can be inserted from a variety of sources: 1. [DOI](https://quarto.org/docs/visual-editor/technical.html#citations-from-dois) (Document Object Identifier) references. 2. [Zotero](https://quarto.org/docs/visual-editor/technical.html#citations-from-zotero) personal or group libraries. 3. Searches of [Crossref](https://www.crossref.org/), [DataCite](https://datacite.org/), or [PubMed](https://pubmed.ncbi.nlm.nih.gov/). 4. Your document bibliography (a `.bib` file in the directory of your document). Balíček *tidyverse* [@tidyverse] je vlastně souborem několika balíčků, včetně např. balíčků *dplyr* [@dplyr]\ nebo *ggplot2* [@ggplot2]. Více citací oddělujeme středníkem [@dplyr; @ggplot2]. Do hranatých závorek lze doplnit libovolné komentáře:\ Blah blah [viz @dplyr, pp. 33--35; a také @ggplot2, kapitola 1]. Když nepoužijeme hranaté závorky, jedná se o citaci autora přímo v textu (v zárorce bude jen rok):\ @dplyr blah blah, nebo @ggplot2 [p. 33] says blah. Pomlčka/znak pro mínus potlačí jméno autora v závorce: Podle Wickhama et al. [-@tidyverse]... Citační styly: ## Další studium ## Citovaná literatura