1 + 1[1] 2
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.
When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
1 + 1[1] 2
2 + 2 [1] 4
You can add options to executable code like this
2 * 2The echo: false option disables the printing of code (only output is displayed).
\[E = mc^2\]
Col1 |
Col2 | Col3 |
|---|---|---|
# load package
library (tidyverse)── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.0 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
# read data
impact <- read_csv ("Data/psz_impact.csv")Rows: 1001 Columns: 11
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (7): DATE_ENTERED, patient_id, gender, Education, language, marital_stat...
dbl (4): AGE, phq9, gad7, visit_count
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
head(impact) #display first six rows# A tibble: 6 × 11
DATE_ENTERED patient_id AGE gender Education language marital_status phq9
<chr> <chr> <dbl> <chr> <chr> <chr> <chr> <dbl>
1 30/1/2020 dErXwHa9Zq 25 Male Secondary … <NA> Married 27
2 31/5/2020 Py7ZM6W5Ib 32 Female Secondary … Urdu Others 10
3 1/8/2020 RxpNzFcCrH 47 Female Secondary … Sindhi Married 27
4 1/8/2020 prHU0DuQNL 32 Female Secondary … Urdu Married 16
5 31/8/2020 Nr7H1s89x3 41 Male Intermedia… Urdu Married 3
6 31/10/2020 Oz2irQP7Xk 35 Female Intermedia… Urdu Married 10
# ℹ 3 more variables: gad7 <dbl>, visit_count <dbl>, tx_status <chr>
library (flextable)
Attaching package: 'flextable'
The following object is masked from 'package:purrr':
compose
flex_impact <- head(impact) |>
flextable()
flex_impact <- set_caption (flex_impact, caption = "Impact Table")
# use pipe to make code more readable
head(impact) |>
flextable() |>
set_caption (caption = "Impact Table")DATE_ENTERED | patient_id | AGE | gender | Education | language | marital_status | phq9 | gad7 | visit_count | tx_status |
|---|---|---|---|---|---|---|---|---|---|---|
30/1/2020 | dErXwHa9Zq | 25 | Male | Secondary or matric | Married | 27 | 18 | 1 | Loss to Follow-up | |
31/5/2020 | Py7ZM6W5Ib | 32 | Female | Secondary or matric | Urdu | Others | 10 | 10 | 1 | Loss to Follow-up |
1/8/2020 | RxpNzFcCrH | 47 | Female | Secondary or matric | Sindhi | Married | 27 | 20 | 1 | Loss to Follow-up |
1/8/2020 | prHU0DuQNL | 32 | Female | Secondary or matric | Urdu | Married | 16 | 18 | 1 | Loss to Follow-up |
31/8/2020 | Nr7H1s89x3 | 41 | Male | Intermediate | Urdu | Married | 3 | 6 | 1 | Loss to Follow-up |
31/10/2020 | Oz2irQP7Xk | 35 | Female | Intermediate | Urdu | Married | 10 | 7 | 1 | Loss to Follow-up |
tip
note
important
caution
warning