引入文件

url_stem <- "https://raw.githubusercontent.com/higgi13425/rmrwr-book/master/"
url_stem
## [1] "https://raw.githubusercontent.com/higgi13425/rmrwr-book/master/"
read_csv(glue(url_stem,'data/strep_tb.tsv'))
## Rows: 107 Columns: 1
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): patient_id  arm dose_strep_g    dose_PAS_g  gender  baseline_condition  ba...
## 
## ℹ 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.
## # A tibble: 107 × 1
##    patient_id\tarm\tdose_strep_g\tdose_PAS_g\tgender\tbaseline_condition\tbase…¹
##    <chr>                                                                        
##  1 "0001\tControl\t0\t0\tM\t1_Good\t1_98-98.9F\t2_11-20\tyes\t1_sens_0-8\t6_Con…
##  2 "0002\tControl\t0\t0\tF\t1_Good\t3_100-100.9F\t2_11-20\tno\t1_sens_0-8\t5_Mo…
##  3 "0003\tControl\t0\t0\tF\t1_Good\t1_98-98.9F\t3_21-50\tno\t1_sens_0-8\t5_Mode…
##  4 "0004\tControl\t0\t0\tM\t1_Good\t1_98-98.9F\t3_21-50\tno\t1_sens_0-8\t5_Mode…
##  5 "0005\tControl\t0\t0\tF\t1_Good\t2_99-99.9F\t3_21-50\tno\t1_sens_0-8\t5_Mode…
##  6 "0006\tControl\t0\t0\tM\t1_Good\t3_100-100.9F\t3_21-50\tno\t1_sens_0-8\t6_Co…
##  7 "0007\tControl\t0\t0\tF\t1_Good\t2_99-99.9F\t3_21-50\tyes\t1_sens_0-8\t5_Mod…
##  8 "0008\tControl\t0\t0\tM\t1_Good\t2_99-99.9F\t3_21-50\tyes\t1_sens_0-8\t5_Mod…
##  9 "0009\tControl\t0\t0\tF\t2_Fair\t2_99-99.9F\t3_21-50\tyes\t1_sens_0-8\t5_Mod…
## 10 "0010\tControl\t0\t0\tM\t2_Fair\t4_100F+\t3_21-50\tyes\t1_sens_0-8\t5_Modera…
## # ℹ 97 more rows
## # ℹ abbreviated name:
## #   ¹​`patient_id\tarm\tdose_strep_g\tdose_PAS_g\tgender\tbaseline_condition\tbaseline_temp\tbaseline_esr\tbaseline_cavitation\tstrep_resistance\tradiologic_6m\trad_num\timproved`

改变数据类型

You can also embed plots, for example:

strep_data <- glue(url_stem,'data/strep_tb.tsv')
strep_tb_cols <- read_tsv(
  file = strep_data,
  col_types =  "ccddfffff--il"                    )
glimpse(strep_tb_cols)
## Rows: 107
## Columns: 11
## $ patient_id          <chr> "0001", "0002", "0003", "0004", "0005", "0006", "0…
## $ arm                 <chr> "Control", "Control", "Control", "Control", "Contr…
## $ dose_strep_g        <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ dose_PAS_g          <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
## $ gender              <fct> M, F, F, M, F, M, F, M, F, M, F, M, F, M, F, M, F,…
## $ baseline_condition  <fct> 1_Good, 1_Good, 1_Good, 1_Good, 1_Good, 1_Good, 1_…
## $ baseline_temp       <fct> 1_98-98.9F, 3_100-100.9F, 1_98-98.9F, 1_98-98.9F, …
## $ baseline_esr        <fct> 2_11-20, 2_11-20, 3_21-50, 3_21-50, 3_21-50, 3_21-…
## $ baseline_cavitation <fct> yes, no, no, no, no, no, yes, yes, yes, yes, no, y…
## $ rad_num             <int> 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, 5,…
## $ improved            <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TR…

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.