fill {neuroim} | R Documentation |
Generic function to map values from one set to another using a user-supplied lookup table
Description
Generic function to map values from one set to another using a user-supplied lookup table
Usage
fill(x, lookup)
## S4 method for signature 'BrainVolume,list'
fill(x, lookup)
## S4 method for signature 'BrainVolume,matrix'
fill(x, lookup)
Arguments
x |
the object to map values from |
lookup |
the lookup table. The first column is the "key" the second column is the "value". |
Value
a new object where the original values have been filled in with the values in the lookup table
Examples
x <- BrainSpace(c(10,10,10), c(1,1,1))
vol <- BrainVolume(sample(1:10, 10*10*10, replace=TRUE), x)
## lookup table is list
lookup <- lapply(1:10, function(i) i*10)
ovol <- fill(vol, lookup)
## lookup table is matrix. First column is key, second column is value
names(lookup) <- 1:length(lookup)
lookup.mat <- cbind(as.numeric(names(lookup)), unlist(lookup))
ovol2 <- fill(vol, lookup.mat)
all.equal(as.vector(ovol2), as.vector(ovol))
[Package neuroim version 0.0.6 Index]