r-hub / pkgsearch

Search R packages on CRAN
https://r-hub.github.io/pkgsearch
Other
108 stars 9 forks source link

How does AND work in search #99

Closed maelle closed 4 years ago

maelle commented 4 years ago

I.e. I'd expect to get 66 hits for the search pkgsearch::advanced_search(VignetteBuilder = "knitr AND rmarkdown") like when following Julia Silge's blog post

cran <- tools::CRAN_package_db()

# the returned data frame has two columns with the same name???
cran <- cran[,-65]

# make it a tibble
cran <- tibble::as_tibble(cran)

dplyr::count(cran, VignetteBuilder, sort = TRUE)
#> # A tibble: 29 x 2
#>    VignetteBuilder             n
#>    <chr>                   <int>
#>  1 <NA>                    11101
#>  2 knitr                    4279
#>  3 R.rsp                     198
#>  4 knitr, rmarkdown           46
#>  5 knitr, R.rsp               38
#>  6 utils, knitr               10
#>  7 R.rsp, knitr                9
#>  8 rmarkdown, knitr            9
#>  9 utils                       9
#> 10 knitr, rmarkdown, R.rsp     6
#> # … with 19 more rows
dplyr::filter(
  cran,
  grepl("rmarkdown", VignetteBuilder),
  grepl("knitr", VignetteBuilder)
)$Package
#>  [1] "AMR"                   "BIGL"                  "ciTools"              
#>  [4] "CoopGame"              "cyphr"                 "data.tree"            
#>  [7] "denoiSeq"              "drugCombo"             "eikosograms"          
#> [10] "ergm"                  "fitHeavyTail"          "gasfluxes"            
#> [13] "GFD"                   "ggTimeSeries"          "gprofiler2"           
#> [16] "grainscape"            "idiogramFISH"          "imputeFin"            
#> [19] "LTRCtrees"             "MANOVA.RM"             "MiRKAT"               
#> [22] "NetLogoR"              "nlpred"                "odr"                  
#> [25] "optband"               "PCMBase"               "PCMBaseCpp"           
#> [28] "PMCMRplus"             "polyCub"               "polyRAD"              
#> [31] "portfolioBacktest"     "POUMM"                 "ppclust"              
#> [34] "prettydoc"             "QFASA"                 "qualvar"              
#> [37] "quickPlot"             "radiomics"             "RcppNumerical"        
#> [40] "reproducible"          "riskParityPortfolio"   "robvis"               
#> [43] "RSpectra"              "SeqKat"                "sequenza"             
#> [46] "showtext"              "sim1000G"              "SpaDES"               
#> [49] "SpaDES.addins"         "SpaDES.core"           "sparseIndexTracking"  
#> [52] "spathial"              "spectralGraphTopology" "SSDM"                 
#> [55] "stylest"               "SubgrPlots"            "supc"                 
#> [58] "SuperLearner"          "sweidnumbr"            "tergm"                
#> [61] "utf8"                  "VCA"                   "VFP"                  
#> [64] "visNetwork"            "wrProteo"              "zooaRch"

pkgsearch::advanced_search(VignetteBuilder = "knitr AND rmarkdown")
#> - "advanced search" -------------------------- 3812 packages in 0.007 seconds -
#>   #     package        version by                         @ title              
#>   1 100 tufterhandout  1.2.1   Michael C Sachs           5y Tufte-style html...
#>   2  98 downloadthis   0.2.0   Felipe Mattioni Maturana 28d Implement Downlo...
#>   3  91 posterdown     1.0     Brent Thorne              8M Generate PDF Con...
#>   4  87 knitrBootstrap 1.0.2   Jim Hester                2y 'knitr' Bootstra...
#>   5  87 texPreview     1.4.4   Jonathan Sidi             4M Compile and Prev...
#>   6  87 rmarkdown      2.2     Yihui Xie                 2d Dynamic Document...
#>   7  86 linl           0.0.4   Dirk Eddelbuettel         7M 'linl' is not 'L...
#>   8  85 details        0.2.1   Jonathan Sidi             5M Create Details H...
#>   9  85 rjdmarkdown    0.1.0   Alain Quartier-la-Tente  24d 'rmarkdown' Exte...
#>  10  83 BDP2           0.1.3   Manuel Wiesenfarth        2y Bayesian Adaptiv...

Created on 2020-06-02 by the reprex package (v0.3.0)

Cf https://github.com/r-lib/usethis/issues/1147

maelle commented 4 years ago

See e.g. https://github.com/cran/tufterhandout/blob/5618b2415844dfc5cb2ea3a0cb26464a21bc5aeb/DESCRIPTION#L16

jennybc commented 4 years ago

Here are 2 ways to get the search you want (I upgraded pkgsearch and now I too have pkgsearch::advanced_search()!):

library(pkgsearch)

x <- advanced_search(
  VignetteBuilder = "knitr", VignetteBuilder = "rmarkdown",
  size = 75
)
nrow(x)
#> [1] 72

x <- advanced_search(
  "VignetteBuilder: knitr AND VignetteBuilder: rmarkdown",
  size = 75
)
nrow(x)
#> [1] 72

Created on 2020-06-01 by the reprex package (v0.3.0.9001)

maelle commented 4 years ago

oooooh thank you!

It's different from how advanced_search(Author = "Hester AND NOT Wickham") works :thinking:

maelle commented 4 years ago

I.e.

pkgsearch::advanced_search(Author = "Hester AND Wickham")
#> - "advanced search" ---------------------------- 16 packages in 0.007 seconds -
#>   #     package     version by             @ title                             
#>   1 100 pkgbuild    1.0.8   Jim Hester   26d Find Tools Needed to Build R Pa...
#>   2  87 memoise     1.1.0   Jim Hester    3y Memoisation of Functions          
#>   3  80 sessioninfo 1.1.1   Gábor Csárdi  2y R Session Information             
#>   4  69 odbc        1.2.2   Jim Hester    5M Connect to ODBC Compatible Data...
#>   5  68 pkgload     1.1.0   Jim Hester    4d Simulate Package Installation a...
#>   6  67 xml2        1.3.2   Jim Hester    1M Parse XML                         
#>   7  67 devtools    2.3.0   Jim Hester    2M Tools to Make Developing R Pack...
#>   8  66 withr       2.2.0   Jim Hester    1M Run Code 'With' Temporarily Mod...
#>   9  63 fs          1.4.1   Jim Hester    2M Cross-Platform File System Oper...
#>  10  61 remotes     2.1.1   Jim Hester    4M R Package Installation from Rem...
pkgsearch::advanced_search(Author = "Hester", Author = "Wickham")
#> - "advanced search" ---------------------------- 16 packages in 0.001 seconds -
#>   #     package     version by             @ title                             
#>   1 100 pkgbuild    1.0.8   Jim Hester   26d Find Tools Needed to Build R Pa...
#>   2  87 memoise     1.1.0   Jim Hester    3y Memoisation of Functions          
#>   3  80 sessioninfo 1.1.1   Gábor Csárdi  2y R Session Information             
#>   4  69 odbc        1.2.2   Jim Hester    5M Connect to ODBC Compatible Data...
#>   5  67 xml2        1.3.2   Jim Hester    1M Parse XML                         
#>   6  66 withr       2.2.0   Jim Hester    1M Run Code 'With' Temporarily Mod...
#>   7  62 pkgload     1.1.0   Jim Hester    4d Simulate Package Installation a...
#>   8  60 devtools    2.3.0   Jim Hester    2M Tools to Make Developing R Pack...
#>   9  59 remotes     2.1.1   Jim Hester    4M R Package Installation from Rem...
#>  10  59 fs          1.4.1   Jim Hester    2M Cross-Platform File System Oper...

Created on 2020-06-02 by the reprex package (v0.3.0)

So I was expecting the same for VignetteBuilder.

maelle commented 4 years ago

(although I see the scores are different)

gaborcsardi commented 4 years ago

I think Author = "Hester AND Wickham" means (Author: Hester) AND (Wickham). I.e. Wickham may appear in any field.

maelle commented 4 years ago

Aaah ok. I guess this could/should be added in the comments (in the examples).

gaborcsardi commented 4 years ago

Which is not great, but you can only do so much w/o parsing the arguments.