Select and copy a range of PTCells from a
PTPattern into a PTBlock. This
allows a more flexible approach to select and modify
PTCells and paste the modified cells back into
a PTPattern.
Arguments
- pattern
A
PTPatternobject from which thePTBlockneeds to be selected.- row
A
numericindex or indices of rows that needs to be copied from thepatterninto the PTBlock.- track
A
numericindex or indices of tracks that needs to be copied from thepatterninto the PTBlock.
Value
Returns a matrix from the selected rows and tracks
from the pattern. Each element in the matrix is a list holding
a single PTCell.
Details
Most objects in this ProTrackR package are very strict in the operations that are allowed, in order to guarantee validity and compatibility with the original ProTracker. This makes those objects not very flexible.
This PTBlock is not a formal S4 object, in fact you
can hardly call it an object at all. It is just a matrix, where each
element holds a list with a single PTCell.
This matrix is very flexible and makes it easier to select and modify
the cells. This flexibility comes at a cost as validity is only checked
at the level of the PTCells. The PTBlock
can be pasted back into a PTPattern with the
pasteBlock method. At which point validity will be checked again. If your modifications
resulted in violation of ProTracker standards, you should not be able to
paste the block into a pattern.
See also
Other block.operations:
pasteBlock()
Examples
data("mod.intro")
## in most ProTrackR methods you can only select a single row or track.
## with a PTBlock your selection is more flexible.
## select rows 4 up to 8 and tracks 2 up to 4, from the first
## pattern table in mod.intro:
block <- PTBlock(PTPattern(mod.intro, 1), 4:8, 2:4)
## 'block' is now a matrix with in each a list with a PTCell.
## These can now easily be accessed and modified:
cell1 <- block[1, 1][[1]]
print(cell1)
#> [1] "C-3 02 000"