Code Monkey home page Code Monkey logo

Comments (1)

Bisaloo avatar Bisaloo commented on June 4, 2024

This is not necessary as names() is called by colnames() for data.frame.

Reprex confirming this:

library(outbreaks)
library(linelist)

## create linelist
x <- make_linelist(measles_hagelloch_1861,
  id = "case_ID",
  date_onset = "date_of_prodrome",
  age = "age",
  gender = "gender"
)

head(x)
#> 
#> // linelist object
#>   case_ID infector date_of_prodrome date_of_rash date_of_death age gender
#> 1       1       45       1861-11-21   1861-11-25          <NA>   7      f
#> 2       2       45       1861-11-23   1861-11-27          <NA>   6      f
#> 3       3      172       1861-11-28   1861-12-02          <NA>   4      f
#> 4       4      180       1861-11-27   1861-11-28          <NA>  13      m
#> 5       5       45       1861-11-22   1861-11-27          <NA>   8      f
#> 6       6      180       1861-11-26   1861-11-29          <NA>  12      m
#>   family_ID class complications x_loc y_loc
#> 1        41     1           yes 142.5 100.0
#> 2        41     1           yes 142.5 100.0
#> 3        41     0           yes 142.5 100.0
#> 4        61     2           yes 165.0 102.5
#> 5        42     1           yes 145.0 120.0
#> 6        42     2           yes 145.0 120.0
#> 
#> // tags: id:case_ID, date_onset:date_of_prodrome, gender:gender, age:age

colnames(x)[1] <- "case_label"

head(x)
#> 
#> // linelist object
#>   case_label infector date_of_prodrome date_of_rash date_of_death age gender
#> 1          1       45       1861-11-21   1861-11-25          <NA>   7      f
#> 2          2       45       1861-11-23   1861-11-27          <NA>   6      f
#> 3          3      172       1861-11-28   1861-12-02          <NA>   4      f
#> 4          4      180       1861-11-27   1861-11-28          <NA>  13      m
#> 5          5       45       1861-11-22   1861-11-27          <NA>   8      f
#> 6          6      180       1861-11-26   1861-11-29          <NA>  12      m
#>   family_ID class complications x_loc y_loc
#> 1        41     1           yes 142.5 100.0
#> 2        41     1           yes 142.5 100.0
#> 3        41     0           yes 142.5 100.0
#> 4        61     2           yes 165.0 102.5
#> 5        42     1           yes 145.0 120.0
#> 6        42     2           yes 145.0 120.0
#> 
#> // tags: id:case_label, date_onset:date_of_prodrome, gender:gender, age:age

Created on 2023-10-11 with reprex v2.0.2

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.1 (2023-06-16)
#>  os       Ubuntu 22.04.3 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language en_US
#>  collate  en_GB.UTF-8
#>  ctype    en_GB.UTF-8
#>  tz       Europe/Paris
#>  date     2023-10-11
#>  pandoc   3.1.1 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version    date (UTC) lib source
#>  backports     1.4.1      2021-12-13 [1] RSPM
#>  checkmate     2.2.0      2023-04-27 [1] RSPM
#>  cli           3.6.1      2023-03-23 [1] RSPM
#>  digest        0.6.33     2023-07-07 [1] CRAN (R 4.3.1)
#>  dplyr         1.1.3      2023-09-03 [1] RSPM (R 4.3.1)
#>  evaluate      0.22       2023-09-29 [1] RSPM (R 4.3.0)
#>  fansi         1.0.5      2023-10-08 [1] RSPM (R 4.3.0)
#>  fastmap       1.1.1      2023-02-24 [1] RSPM
#>  fs            1.6.3      2023-07-20 [1] RSPM (R 4.3.1)
#>  generics      0.1.3      2022-07-05 [1] RSPM
#>  glue          1.6.2      2022-02-24 [1] RSPM
#>  htmltools     0.5.6.1    2023-10-06 [1] RSPM (R 4.3.0)
#>  knitr         1.44.1     2023-09-22 [1] Github (yihui/knitr@42f6b3a)
#>  lifecycle     1.0.3      2022-10-07 [1] RSPM
#>  linelist    * 1.0.0      2023-10-11 [1] Github (epiverse-trace/linelist@e1aacba)
#>  magrittr      2.0.3      2022-03-30 [1] RSPM
#>  outbreaks   * 1.9.0      2020-09-28 [1] RSPM (R 4.3.0)
#>  pillar        1.9.0      2023-03-22 [1] RSPM
#>  pkgconfig     2.0.3      2019-09-22 [1] RSPM
#>  purrr         1.0.2.9000 2023-09-15 [1] Github (tidyverse/purrr@ac4f5a9)
#>  R.cache       0.16.0     2022-07-21 [1] RSPM
#>  R.methodsS3   1.8.2      2022-06-13 [1] RSPM
#>  R.oo          1.25.0     2022-06-12 [1] RSPM
#>  R.utils       2.12.2     2022-11-11 [1] RSPM
#>  R6            2.5.1      2021-08-19 [1] RSPM
#>  reprex        2.0.2      2022-08-17 [1] RSPM
#>  rlang         1.1.1      2023-04-28 [1] RSPM (R 4.3.0)
#>  rmarkdown     2.25       2023-09-18 [1] CRAN (R 4.3.1)
#>  rstudioapi    0.15.0     2023-07-07 [1] CRAN (R 4.3.1)
#>  sessioninfo   1.2.2      2021-12-06 [1] RSPM
#>  styler        1.10.1     2023-06-05 [1] CRAN (R 4.3.1)
#>  tibble        3.2.1      2023-03-20 [1] RSPM
#>  tidyselect    1.2.0      2022-10-10 [1] RSPM
#>  utf8          1.2.3      2023-01-31 [1] RSPM
#>  vctrs         0.6.3      2023-06-14 [1] RSPM (R 4.3.0)
#>  withr         2.5.1      2023-09-26 [1] RSPM (R 4.3.0)
#>  xfun          0.40       2023-08-09 [1] RSPM (R 4.3.1)
#>  yaml          2.3.7      2023-01-23 [1] RSPM (R 4.3.0)
#> 
#>  [1] /home/hugo/.local/share/R/x86_64-pc-linux-gnu-library/4.3
#>  [2] /usr/local/lib/R/site-library
#>  [3] /usr/lib/R/site-library
#>  [4] /usr/lib/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────

from linelist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.