Packages with names starting with Rcpp and tidy

I want to know how many R packages have names starting with 'Rcpp' and 'tidy'. For example, RcppRoll and tidycensus, etc. :grinning:

 $ 530:  wc rcpp tidy
      44     336    5820 rcpp
      23     176    2999 tidy
      67     512    8819 total
 $ 531:

of course. Let me know if you want the secret sauce to quickly run this. :grinning: Just kiding:

Auxiliary files

html.top

Auxiliary files

html.top


<!DOCTYPE html>
<html>
<head>
    <title></title>
</head>
<body>
<table>

html.bot

</table>
</body>
</html>

Bash script (unparameterized)

curl https://cran.r-project.org/web/packages/available_packages_by_name.html > packages.html
grep packages.Rcpp packages.html > rcpp
grep packages.tidy packages.html > tidy
cat html.top > results.html
cat rcpp >> results.html
cat tidy >> results.html
cat html.bot >> results.html
sed -i .bak 's/.......web.packages/"https:\/\/cran.r-project.org\/web\/packages/g'  results.html

Example script output

1 Like

Could you do it with R code?

Probably

  1. R can read HTML
  2. R can search
  3. R can save search results
  4. R can read plain text (header and footer)
  5. R can do search and replace to fix the ../web type references, or I suppose I could have set a base url, but my HTML hasn't seen a lot of use in a while
  6. R has `paste' to concatenate strings
  7. R has functions, which could be used to construct a `findRpkg('Rccp') and do this all
  8. R knows how to invoke the external browser

So, yes. All the tools are there and don't require opening a terminal session to execute the script.

No need to scrape the web :slight_smile:

pkgs <- rownames(available.packages())
sum(startsWith(pkgs,"tidy")) # 23
sum(startsWith(pkgs,"Rcpp")) # 43
2 Likes

@Moody_Mudskipper answered the question that the OP asked, which is how many, while I blew past that and read it as "what are?". Bad @technocrat

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.