No Clocks

No Clocks

4146 bookmarks
Newest
GeoRust
GeoRust
·georust.org·
GeoRust
3 Package structure and state – R Packages (2e)
3 Package structure and state – R Packages (2e)
Learn how to create a package, the fundamental unit of shareable, reusable, and reproducible R code.
Package development workflows make much more sense if you understand the five states an R package can be in: source bundled binary installed in-memory
You already know some of the functions that put packages into these states. For example, install.packages() can move a package from the source, bundled, or binary states into the installed state. devtools::install_github() takes a source package on GitHub and moves it into the installed state. The library() function loads an installed package into memory, making it available for immediate and direct use.
A source package is just a directory of files with a specific structure. It includes particular components, such as a DESCRIPTION file, an R/ directory containing .R files, and so on. Most of the remaining chapters in this book are dedicated to detailing these components.
A bundled package is a package that’s been compressed into a single file. By convention (from Linux), package bundles in R use the extension .tar.gz and are sometimes referred to as “source tarballs”. This means that multiple files have been reduced to a single file (.tar) and then compressed using gzip (.gz). While a bundle is not that useful on its own, it’s a platform-agnostic, transportation-friendly intermediary between a source package and an installed package.
In the rare case that you need to make a bundle from a package you’re developing locally, use devtools::build(). Under the hood, this calls pkgbuild::build() and, ultimately, R CMD build, which is described further in the Building package tarballs section of Writing R Extensions.
This should tip you off that a package bundle or “source tarball” is not simply the result of making a tar archive of the source files, then compressing with gzip. By convention, in the R world, a few more operations are carried out when making the .tar.gz file and this is why we’ve elected to refer to this form as a package bundle, in this book.
Every CRAN package is available in bundled form, via the “Package source” field of its landing page.
The main differences between a source package and an uncompressed bundle are: Vignettes have been built, so rendered outputs, such as HTML, appear below inst/doc/ and a vignette index appears in the build/ directory. A local source package might contain temporary files used to save time during development, like compilation artefacts in src/. These are never found in a bundle. Any files listed in .Rbuildignore are not included in the bundle. These are typically files that facilitate your development process, but that should be excluded from the distributed product.
Each line of .Rbuildignore is a Perl-compatible regular expression that is matched, without regard to case, against the path to each file in the source package1. If the regular expression matches, that file or directory is excluded. Note there are some default exclusions implemented by R itself, mostly relating to classic version control systems and editors, such as SVN, Git, and Emacs.
We usually modify .Rbuildignore with the usethis::use_build_ignore() function, which takes care of easy-to-forget details, such as regular expression anchoring and escaping. To exclude a specific file or directory (the most common use case), you MUST anchor the regular expression. For example, to exclude a directory called “notes”, the .Rbuildignore entry must be ^notes$, whereas the unanchored regular expression notes will match any file name containing “notes”, e.g. R/notes.R, man/important-notes.R, data/endnotes.Rdata, etc. We find that use_build_ignore() helps us get more of our .Rbuildignore entries right the first time.
.Rbuildignore is a way to resolve some of the tension between the practices that support your development process and CRAN’s requirements for submission and distribution (Chapter 22). Even if you aren’t planning to release on CRAN, following these conventions will allow you to make the best use of R’s built-in tooling for package checking and installation. The files you should .Rbuildignore fall into two broad, semi-overlapping classes: Files that help you generate package contents programmatically. Examples: Using README.Rmd to generate an informative and current README.md (Section 18.1). Storing .R scripts to create and update internal or exported data (Section 7.1.1). Files that drive package development, checking, and documentation, outside of CRAN’s purview. Examples: Files relating to the RStudio IDE (Section 4.2). Using the pkgdown package to generate a website (Chapter 19). Configuration files related to continuous integration/deployment (Section 20.2).
Here is a non-exhaustive list of typical entries in the .Rbuildignore file for a package in the tidyverse: ^.*\.Rproj$ # Designates the directory as an RStudio Project ^\.Rproj\.user$ # Used by RStudio for temporary files ^README\.Rmd$ # An Rmd file used to generate README.md ^LICENSE\.md$ # Full text of the license ^cran-comments\.md$ # Comments for CRAN submission ^data-raw$ # Code used to create data included in the package ^pkgdown$ # Resources used for the package website ^_pkgdown\.yml$ # Configuration info for the package website ^\.github$ # GitHub Actions workflows
If you want to distribute your package to an R user who doesn’t have package development tools, you’ll need to provide a binary package. The primary maker and distributor of binary packages is CRAN, not individual maintainers. But even if you delegate the responsibility of distributing your package to CRAN, it’s still important for a maintainer to understand the nature of a binary package.
Binary packages for macOS are stored as .tgz, whereas Windows binary packages end in .zip. If you need to make a binary package, use devtools::build(binary = TRUE) on the relevant operating system. Under the hood, this calls pkgbuild::build(binary = TRUE) and, ultimately, R CMD INSTALL --build, which is described further in the Building binary packages section of Writing R Extensions. If you choose to release your package on CRAN (Chapter 22), you submit your package in bundled form, then CRAN creates and distributes the package binaries.
An installed package is a binary package that’s been decompressed into a package library (described in Section 3.7). Figure 3.2 illustrates the many ways a package can be installed, along with a few other functions for converting a package from one state to another. This diagram is complicated! In an ideal world, installing a package would involve stringing together a set of simple steps: source -> bundle, bundle -> binary, binary -> installed. In the real world, it’s not this simple because there are often (faster) shortcuts available.
·r-pkgs.org·
3 Package structure and state – R Packages (2e)
Playing with AI Agents in R - cynkra
Playing with AI Agents in R - cynkra
It's local LLM time! What an adventure it has been since I first started exploring local LLMs. With the introduction of various new Llama models, we now have impressive small and large models that run seamlessly on consumer hardware.
·cynkra.com·
Playing with AI Agents in R - cynkra
BaseClaw/SKILL.md at main · jweingardt12/BaseClaw
BaseClaw/SKILL.md at main · jweingardt12/BaseClaw
Win your fantasy league, with the help of AI. Allows for Claude/OpenClaw management of your Yahoo Fantasy Baseball team. - jweingardt12/BaseClaw
·github.com·
BaseClaw/SKILL.md at main · jweingardt12/BaseClaw
rafi/awesome-cli-binaries: Popular modern Linux CLI utilities, with pre-made statically compiled amd64/arm64 binaries and a great ~/.config starting point 🎉
rafi/awesome-cli-binaries: Popular modern Linux CLI utilities, with pre-made statically compiled amd64/arm64 binaries and a great ~/.config starting point 🎉
Popular modern Linux CLI utilities, with pre-made statically compiled amd64/arm64 binaries and a great ~/.config starting point 🎉 - rafi/awesome-cli-binaries
·github.com·
rafi/awesome-cli-binaries: Popular modern Linux CLI utilities, with pre-made statically compiled amd64/arm64 binaries and a great ~/.config starting point 🎉
Optimizing Windows for Productivity and Performance
Optimizing Windows for Productivity and Performance
Hi everyone, I’m Fahadi Jutt, working in IT and always interested in making Windows systems run smoother and more efficiently. I’d love to hear what strategies or tools you use to optimize...
·windowsforum.com·
Optimizing Windows for Productivity and Performance
Reading Remote Data Files
Reading Remote Data Files
Sometimes data arrives as a series of individual files each of which is organized in the same way—which is to say, each of which has the same variables, features, or columns. Imagine a series of tables reporting mandated information about every s...
·r-bloggers.com·
Reading Remote Data Files
Developer Portal
Developer Portal
JSON Template (JSON-T) is a minimal but powerful template language, designed to be paired with a JSON dataset. This data is provided by Squarespace and is dynamically generated, containing all of your site content.
·developers.squarespace.com·
Developer Portal
Error Codes
Error Codes
Making It Go
·patton-tech.com·
Error Codes
Querying PowerShell Gallery and Nuget.org
Querying PowerShell Gallery and Nuget.org
I’ve decided that I want to changeup how I display my projects on the blog, I think I could create a landing page for all my code and then create dedicated locations for things that are published. Additionally I think it would be fun to see some of the stats displayed here, which is easy enough for an individual project, but not for a large group. This got me thinking how can I query nuget.org and powershellgallery.com for a list of packages that I’ve published.
·patton-tech.com·
Querying PowerShell Gallery and Nuget.org
PowerShell: Calculating Folder Sizes
PowerShell: Calculating Folder Sizes
Sometimes all you want to know, or need to know, is how big a folder is in PowerShell. To do that, we'll need to use Get-ChildItem and Measure-Object specifically.The quick and dirtyThe first command...
·gnja.io·
PowerShell: Calculating Folder Sizes
AI Skills for R Package Development
AI Skills for R Package Development
A collection of curated, opinionated skills and agent instructions to improve agentic coding of R packages.
·pkgskills.api2r.org·
AI Skills for R Package Development
Simple Foreign Function Interface using S7 and libffi
Simple Foreign Function Interface using S7 and libffi
Simple Foreign Function Interface for R using libffi and S7 classes. Supports calling C functions with type conversion and struct handling. Includes standard C types (int8, int16, int32, int64, uint variants), platform types (size_t, bool), floating point types, and complex struct types. Experimental header parsing using tinycc as `C` preprocessor enables automatic generation of R bindings from C header files, simplifying package development for C libraries.
·sounkou-bioinfo.github.io·
Simple Foreign Function Interface using S7 and libffi
Understand EPSG, WKT and Other CRS Definition Styles
Understand EPSG, WKT and Other CRS Definition Styles
Coordinate Reference System (CRS) information is often stored in three key formats, including proj.4, EPSG and WKT. Learn more about the ways that coordinate reference system data are stored including proj4, well known text (wkt) and EPSG codes.
·earthdatascience.org·
Understand EPSG, WKT and Other CRS Definition Styles
c++ - Determining Which Compiler Built a Win32 PE - Stack Overflow
c++ - Determining Which Compiler Built a Win32 PE - Stack Overflow
How can one determine which C or C++ compiler was used to build a particular Windows executable or DLL? Some compilers leave behind version strings in the final executable, but this seems to be rar...
·stackoverflow.com·
c++ - Determining Which Compiler Built a Win32 PE - Stack Overflow
Data serialisation in R – Notes from a data witch
Data serialisation in R – Notes from a data witch
A terrifying descent into madness, or, an explanation of how R serialises an in-memory data structure to summon a sequence of bytes that can be saved or transmitted. Eldritch horrors are unleashed by reading occult texts such as the R internals manual, SEXPTYPE codes are extracted from RDS with bitwise logic, and in the dark conclusion the R source code is consulted
·blog.djnavarro.net·
Data serialisation in R – Notes from a data witch
Go Optimization Guide
Go Optimization Guide
Patterns and Techniques for Writing High-Performance Applications with Go
·goperf.dev·
Go Optimization Guide