Similar projects and alternatives to box
Easily create reusable command line scripts with R
An implementation of the Grammar of Graphics in R
Scout APM: A developer's best friend. Try free for 14-days. Scout APM uses tracing logic that ties bottlenecks to source code so you know the exact line of code causing performance issues and can get back to building a great product faster.
Static Code Analysis for R
renv: Project environments for R.
Tidy interface to 'data.table'
Module for functional programming in R
A bridge between R and Nim
SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives
This package is a wrapper for HMRC's newly released API. It provides convenient functions to load Overseas Trade Statistics, Regional Trade Statistics, and trader data. It also provides a function for loading custom URLs.
best way to set current directory to working directory
reddit.com/r/rstats | 2021-06-24
Yes: don’t use setwd and either use the project-based workflow already discussed in other answers, or use ‘box’, and then use box::file to find files stored relative to the current module. This works even more reliably than ‘here’, in fact, since it makes fewer assumptions about the project structure.
Creating your own R package
reddit.com/r/rstats | 2021-05-30
I'll also name drop the Box package, which serves like a middle of the road option between creating packages and sourcing scripts. It allows you to treat scripts (and the functions inside them) like packages without having to go through all the extra steps to build packages. In that way, it's more similar to creating and importing python modules.
R versus other programming languages
reddit.com/r/Rlanguage | 2021-05-19
Shameless plug: Using ‘box’ to write modular, reusable code. Writing R packages requires comparatively large effort, and simple R scripts have various deficiencies.
import a function from a package
reddit.com/r/rstats | 2021-05-17
Incidentally, if you often write code like this (= import individual functions from packages rather than attaching the whole package), check out the ‘box’ package, it provides a systematic solution for this.
import functions from a package without loading the package
reddit.com/r/rstats | 2021-04-10
I don't fully understand what happens when you attach a package, so I can't speak to your question about side-effects. However, if you're looking for an alternative, possibly safer, strategy, you might try the package box.reddit.com/r/rstats | 2021-04-10
There is: use the ‘box’ package. It allows this and more. In your specific case, you’d write
Reference project for an R 2+2=4 style application coverage, testthat and a build file
reddit.com/r/Rlanguage | 2021-03-31
That said, I’ve been playing with a framework for command line applications in R (as a ‘box’ module), and I guess you could call the example application “2+2=4” style (it’s a command line calculator, complete with automatically generated option parser etc.).
Rcpp compilation time
reddit.com/r/rstats | 2021-03-30
You shouldn’t be running cpp_source more than once on the same file. If you want to use C++ code in reusable code, put it into a package (or a module).
What would you like to see from an R2 / R++ / R#
reddit.com/r/Rlanguage | 2021-03-27
You can do that with ‘box’, check it out!
Relative path problem
reddit.com/r/Rlanguage | 2021-03-19
For regular code, there are several workarounds. But IMHO the simplest is to use the package ‘box’ (disclaimer: I’m the author) to organise your code. This will allow you to use box::file() in pretty much the same way as you can use system.file() inside packages, except it works everywhere, and it also works with nonexistent (or not-yet-existent) files (system.file only works for files that already exist).
Need help in function writing
reddit.com/r/rstats | 2021-02-24
Rather, don’t use *either*** inside a functions, since using them has a global side-effect. Either load all required packages outside the function, or (ideally) write the function in such a way that it doesn’t depend on the global package search path. Either by qualifying all package access explicitly (via e.g. dplyr::…) or by using the ‘box’ package to load packages locally.
New package ‘box’: Write reusable, composable and modular R code
For one thing, I’ve (for now) decided that ‘box’ won’t automatically install packages. I might revisit this in the future (there’s already a related feature request) but I generally think that this doesn’t scale: virtually every other programming language environment cleanly separates installation/management and usage of dependencies. Go used to mix installation and usage, but as far as I know the Go community has now switched, and also splits installation/dependency management (via dep) and usage/import, because they found that the mixed approach doesn’t work.
There’s a lot more to it, so if you’re curious please head over to the website and check out the README and “Get started” vignette.
Automating script within a project
reddit.com/r/rstats | 2021-02-10
How are you launching the script? If you’re using R CMD BATCH, Rscript or similar, give ‘box’ a try. It requires some limited rewriting of your scripts, but the upshot is that instead of source(here('R', 'scriptname.R')) you’d do the following, and this should just work, regardless of whether you launch the script manually or via the task scheduler:
klmr/box is an open source project licensed under MIT License which is an OSI approved license.