Title: A Tool to Downsize Large Analysis Projects for Testing
Version: 0.2.3
Description: Toggles the test and production versions of a large data analysis project.
License: GPL (≥ 3)
Depends: R (≥ 3.0.0)
Imports: magrittr, R.utils, utils
Suggests: knitr, rmarkdown, testthat
VignetteBuilder: knitr
URL: https://github.com/wlandau/downsize
BugReports: https://github.com/wlandau/downsize/issues
RoxygenNote: 7.2.3
Encoding: UTF-8
Language: en-US
NeedsCompilation: no
Packaged: 2023-03-16 16:27:56 UTC; c240390
Author: William Michael Landau [aut, cph, cre]
Maintainer: William Michael Landau <will.landau@gmail.com>
Repository: CRAN
Date/Publication: 2023-03-16 17:40:10 UTC

Internal utility function.

Description

Utility function. Make downsized object out of argument small to downsize.

Usage

arg_small(args)

Arguments

args

named list of arguments to downsize

See Also

help_downsize


Internal utility function.

Description

Utility function. Checks that arguments are valid.

Usage

check_args(args)

Arguments

args

named list of arguments to downsize

See Also

help_downsize


Function downsize. Main function of the downsize package.

Description

Replace big with a downsized object if the downsize argument (or the downsize global option) is TRUE. The downsize global option can be toggled with functions test_mode and production_mode. Use the help_downsize function to get more help.

Usage

downsize(
  big,
  small = NULL,
  downsize = getOption("downsize"),
  warn = TRUE,
  random = FALSE,
  length = NULL,
  dim = NULL,
  ncol = NULL,
  nrow = NULL
)

Arguments

big

Object to return if downsize is FALSE or NULL.

small

Object to return if downsize is TRUE and all subsetter arguments such as length and dim are NULL.

downsize

TRUE/FALSE value (NULL counts as FALSE), whether to replace big with a downsized object. Defaults to the global option downsize, which you can check with getOption("downsize") or the my_mode function and set with functions downsize, test_mode or production_mode.

warn

TRUE/FALSE option to warn the user if big and small are identical or big is smaller in memory than small.

random

If TRUE, take a random subset of big instead of the first few elements. For example, if nrow == 3, take a random 3 rows instead of the first 3.

length

Downsize big to this length if downsize is TRUE.

dim

Downsize big to these dimensions if downsize is TRUE.

ncol

Downsize big to this number of columns if downsize is TRUE.

nrow

Downsize big to this number of rows if downsize is TRUE.

Details

Use the help_downsize function to get more help. If the downsize argument is TRUE, a downsized replacement for big will be returned. In this case, argument small takes precedence over subsetter arguments such as dim, length, nrow, and ncol. That is, if small is not NULL, then small will be returned even if dim is not NULL. If the downsize argument is not set manually, the downsize global option will be used. The downsize global option can be toggled with functions test_mode and production_mode.

Value

A downsized object if downsize is TRUE and big otherwise.

See Also

help_downsize, test_mode, production_mode, my_mode


Internal utility function.

Description

Utility function. Throw an error when downsizing fails.

Usage

downsize_error(arg_name)

Arguments

arg_name

name of an argument to downsize

See Also

help_downsize


Function ds. Deprecated.

Description

Deprecated. Use function downsize instead. See help_downsize for help.

Usage

ds(
  big,
  small = NULL,
  downsize = getOption("downsize"),
  warn = TRUE,
  random = FALSE,
  length = NULL,
  dim = NULL,
  ncol = NULL,
  nrow = NULL
)

Arguments

big

Object to return if downsize is FALSE or NULL.

small

Object to return if downsize is TRUE and all subsetter arguments such as length and dim are NULL.

downsize

TRUE/FALSE value (NULL counts as FALSE), whether to replace big with a downsized object. Defaults to the global option downsize, which you can check with getOption("downsize") or the scaling function and set with functions downsize, scale_down or scale_up.

warn

TRUE/FALSE option to warn the user if big and small are identical or big is smaller in memory than small.

random

If TRUE, take a random subset of big instead of the first few elements. For example, if nrow == 3, take a random 3 rows instead of the first 3.

length

Downsize big to this length if downsize is TRUE.

dim

Downsize big to these dimensions if downsize is TRUE.

ncol

Downsize big to this number of columns if downsize is TRUE.

nrow

Downsize big to this number of rows if downsize is TRUE.

Value

A downsized object if downsize is TRUE and big otherwise.

See Also

help_downsize, downsize, scale_down, scale_up, scaling


Function help_downsize

Description

Prints links for tutorials, troubleshooting, bug reports, etc.

Usage

help_downsize()

See Also

downsize, scale_down, scale_up, scaling


Internal utility function.

Description

Utility function. Inside function downsize, make "small" out of "big" by subsetting or some other method. This is called if any of the subsetting arguments to downsize are set (length, dim, etc.)

Usage

make_small(args)

Arguments

args

named list of arguments to downsize

See Also

help_downsize


Function my_mode

Description

Check whether the current workflow is production mode or test mode. Use the help_downsize function to get more help.

Usage

my_mode()

Details

Use the help_downsize function to get more help.

Value

"test mode" if getOption("downsize") is TRUE and "production mode" if getOption("downsize") is FALSE or NULL.

See Also

help_downsize, downsize, test_mode, production_mode


Function production_mode

Description

Calls options(downsize = FALSE) to scale up a workflow to production mode. This affects the downsize function. Use the help_downsize function to get more help.

Usage

production_mode()

Details

Use the help_downsize function to get more help.

See Also

help_downsize, downsize, test_mode, my_mode


Deprecated function scale_down

Description

Deprecated. Use test_mode instead. Calls options(downsize = TRUE) to scale down a workflow. This affects the downsize function. Use the help_downsize function to get more help.

Usage

scale_down()

Details

Use the help_downsize function to get more help.

See Also

help_downsize, test_mode scaling


Deprecated function scale_up

Description

Deprecated. Use production_mode instead. Calls options(downsize = FALSE) to scale up a workflow. This affects the downsize function. Use the help_downsize function to get more help.

Usage

scale_up()

Details

Use the help_downsize function to get more help.

See Also

help_downsize, production_mode


Deprecated function scaling

Description

Deprecated. Use my_mode instead. Checks whether the current workflow is scaled up or down. Use the help_downsize function to get more help.

Usage

scaling()

Details

Use the help_downsize function to get more help.

Value

"scaled down" if getOption("downsize") is TRUE and "scaled up" if getOption("downsize") is FALSE or NULL.

See Also

help_downsize, my_mode


Internal utility function.

Description

Utility function. TRUE/FALSE: should the downsize function return a downsized replacement for "big"?

Usage

should_downsize(downsize)

Arguments

downsize

argument to downsize

See Also

help_downsize


Internal utility function.

Description

Utility function. Subset an object x with a dim attribute (matrix/array/data.frame/etc.) and return another with dimensions pmin(dim, dim(x))

Usage

subset_dim(x, dim, random)

Arguments

x

object to subset

dim

new dimensions

random

logical, whether to take a random subset or just the head.

See Also

help_downsize


Internal utility function.

Description

Utility function. Subset a vector/list/etc. x and return another with length min(length, length(x))

Usage

subset_length(x, length, random)

Arguments

x

object to subset

length

new length

random

logical, whether to take a random subset or just the head.

See Also

help_downsize


Internal utility function.

Description

Utility function. Subset an object x with columns and return another with min(ncol, ncol(x)) columns.

Usage

subset_ncol(x, ncol, random)

Arguments

x

object to subset

ncol

new number of columns

random

logical, whether to take a random subset or just the head.

See Also

help_downsize


Internal utility function.

Description

Utility function. Subset an object x with rows and return another with min(nrow, nrow(x)) columns.

Usage

subset_nrow(x, nrow, random)

Arguments

x

object to subset

nrow

new number of rows

random

logical, whether to take a random subset or just the head.

See Also

help_downsize


Internal utility function.

Description

Utility function. Same as subset_dim, but along the single dimension with index which_dim.

Usage

subset_single_dim(x, which_dim, dim_length, random)

Arguments

x

object to subset

which_dim

index of dimension along which to subset

dim_length

new length/size of the dimension of x with index which_dim

random

logical, whether to take a random subset or just the head.

See Also

help_downsize


Function test_mode

Description

Calls options(downsize = TRUE) to scale down a workflow to test mode. This affects the downsize function. Use the help_downsize function to get more help.

Usage

test_mode()

Details

Use the help_downsize function to get more help.

See Also

help_downsize, downsize, production_mode, my_mode, my_mode


Internal utility function.

Description

Utility function. Should the "small" argument to downsize be used? Returns TRUE if none of the subsetting arguments (length, dim, etc.) or similar is set.

Usage

use_arg_small(args)

Arguments

args

named list of arguments to downsize

See Also

help_downsize