Learn R Programming

wavethresh (version 2.2-6)

uncompress.default: Decompress a Compressed or Uncompressed Object

Description

The compress function compresses a sparse vector by removing zeroes. This function performs the inverse transformation.

Usage

## S3 method for class 'default':
uncompress(v, verbose=FALSE)

Arguments

v
The compressed or uncompressed object to uncompress.
verbose
logical; if true then informative messages are printed.

Value

  • The uncompressed vector.

Details

See compress.default to see what this function does to vectors. The uncompress.default function takes objects that have been output from compress.default(.) and restores them to their original values. If the input to compress.default was a sparse vector, then an object of class compressed would be returned. This class of object (see compressed.object) is a list containing the position and values of all the non-zero elements of the original vector. The uncompress.default function reconstitutes the original vector.

Sometimes compression is not worthwhile (i.e. the original vector is not sparse enough). In this case compress.default() returns the original vector in a list with class uncompressed. The uncompress.default() function's task in this case is simple: only return the vector part of uncompressed.

See Also

compress, compressed.object.

Examples

Run this code
## Compress a sparse vector and look at it
str(cv <- compress( vv <- c(rep(0,100),564) ))

## Uncompress the vector, (uncompress.default is used)
str(ucv <- uncompress(cv))
all(ucv == vv)

## a bit less sparse:
vv[sample(seq(vv), 5)] <- 1:5
str(cv <- compress(vv))
all(vv == uncompress(cv))

Run the code above in your browser using DataLab