Learn R Programming

ff (version 4.5.0)

add: Incrementing an ff or ram object

Description

Yet another assignment interface in order to allow to formulate x[index,...,add=TRUE]<-value in a way which works transparently, not only for ff, but also for ram objects: add(x, value, index, ...).

Usage

add(x, ...)
# S3 method for ff
add(x, value, ...)
# S3 method for default
add(x, value, ...)

Value

invisible()

Arguments

x

an ff or ram object

value

the amount to increment, possibly recylcled

...

further arguments -- especially index information -- passed to [<- or [<-.ff

Author

Jens Oehlschlägel

See Also

swap, [.ff, LimWarn

Examples

Run this code
   message("incrementing parts of a vector")
   x <- ff(0, length=12)
   y <- rep(0, 12)
   add(x, 1, 1:6)
   add(y, 1, 1:6)
   x
   y

   message("incrementing parts of a matrix")
   x <- ff(0, dim=3:4)
   y <- array(0, dim=3:4)
   add(x, 1, 1:2, 1:2)
   add(y, 1, 1:2, 1:2)
   x
   y

   message("BEWARE that ff and ram methods differ in treatment of duplicated index positions")
   add(x, 1, c(3,3))
   add(y, 1, c(3,3))
   x
   y

   rm(x); gc()

Run the code above in your browser using DataLab