I want to know how many R packages have names starting with 'Rcpp' and 'tidy'. For example, RcppRoll and tidycensus, etc.
$ 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. 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
1 Like
Could you do it with R code?
Probably
- R can read HTML
- R can search
- R can save search results
- R can read plain text (header and footer)
- 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
- R has `paste' to concatenate strings
- R has functions, which could be used to construct a `findRpkg('Rccp') and do this all
- 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
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.