Base R's paste and paste0 functions: how to use the sep and collapse arguments (CC285)

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ก.ค. 2024
  • The paste and paste0 functions are powerful tools for creating strings in base R that don't require dependencies. You can even paste together two vectors element-wise separating the values with the sep argument and then paste together all elements of the resulting vector with the collapse argument. Pat will use paste and other base R functions to filter taxonomy data by confidence score and then output the result in an attractive string using paste. This episode is part of an ongoing effort to develop an R package that implements the naive Bayesian classifier.
    If you want to get a physical copy of R Packages: amzn.to/43pMR8L
    If you want a free, online version of R packages: r-pkgs.org/
    You can find my blog post for this episode at www.riffomonas.org/code_club/....
    Check out the GitHub repository at the:
    * Beginning of the episode: github.com/riffomonas/phyloty...
    * End of the episode: github.com/riffomonas/phyloty...
    #rstats #paste #paste0 #refactor #testthat #tdd #microbenchmark #vectors #rdp #16S #classification #classifier #microbialecology #microbiome
    Support Riffomonas by becoming a Patreon member!
    / riffomonas
    Want more practice on the concepts covered in Code Club? You can sign up for my weekly newsletter at shop.riffomonas.org/youtube to get practice problems, tips, and insights.
    If you're interested in purchasing a video workshop be sure to check out riffomonas.org/workshops/
    You can also find complete tutorials for learning R with the tidyverse using...
    Microbial ecology data: www.riffomonas.org/minimalR/
    General data: www.riffomonas.org/generalR/
    0:00 Introduction
    5:23 Filtering taxonomy based on confidence
    12:01 Printing classifications with confidence
    23:23 Finding a bug and refactoring it away
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 4

  • @soyeonkim9355
    @soyeonkim9355 หลายเดือนก่อน

    As always, thank you for your help!😄😄

    • @Riffomonas
      @Riffomonas  หลายเดือนก่อน

      Thanks for watching!

  • @tedhermann3424
    @tedhermann3424 หลายเดือนก่อน

    If you want to avoid the while loop, you could do something like:
    if(n_levels > original_levels) {
    consensus$taxonomy[(original_levels + 1):n_levels]

    • @Riffomonas
      @Riffomonas  หลายเดือนก่อน

      Very slick - thanks for the suggestion!