PTTrack-method: Coerce to or replace PTTrack

PTTrack-methodR Documentation

Coerce to or replace PTTrack

Description

This method will coerce a set of objects to a PTTrack object. It can also be used to select specific tracks from PTModule and PTPattern objects and replace the selected PTTrack.

Usage

## S4 method for signature 'raw,missing,missing'
PTTrack(x)

## S4 method for signature 'matrix,missing,missing'
PTTrack(x)

## S4 method for signature 'character,missing,missing'
PTTrack(x)

## S4 method for signature 'PTModule,numeric,numeric'
PTTrack(x, track, pattern)

## S4 replacement method for signature 'PTModule,numeric,numeric,PTTrack'
PTTrack(x, track, pattern) <- value

## S4 method for signature 'PTPattern,numeric,missing'
PTTrack(x, track)

## S4 replacement method for signature 'PTPattern,numeric,missing,PTTrack'
PTTrack(x, track) <- value

Arguments

x

Object (any of raw data, a 64 by 4 matrix of raw data, a vector of character strings, a PTPattern or a PTModule) to coerce to a PTTrack. See details below for the required format of x

track

When x is a PTPattern, or a PTModule, provide an index [1,4] of the track that needs to be coerced to a PTTrack.

pattern

When x is a PTModule, provide an index of the pattern that needs to be coerced to a PTTrack. Note that ProTracker uses indices for patterns that start at zero, whereas R uses indices that start at one. Hence add one to an index obtained from a PTModule object (e.g., x$pattern.order)

value

An object of PTTrack with which the PTTrack object at the specified indices in object x needs to be replaced.

Details

Method to coerce x to class PTTrack.

When x is a 64 by 4 matrix of raw data, each row implicitly represents a PTCell object and should be formatted accordingly. See PTCell-class documentation for more details.

When x is a 64 element vector of character representation of PTCell objects, the character representation must be conform the specifications as documented at the PTCell-class.

When x is of class PTPattern, or PTModule, the PTTrack at the specified indices (track and pattern) is returned, or can be replaced.

Value

When PTTrack is used, a PTTrack object based on x is returned.

When PTTrack<- is used, object x is returned in which the selected PTTrack is replaced with value.

Author(s)

Pepijn de Vries

See Also

Other track.operations: as.character()

Examples

## This will create an 'empty' PTTrack with all nul
## values, which is equivalent to new("PTTrack"):
PTTrack(as.raw(0x00))

## This will generate a PTTrack from a repeated
## character representation of a PTCell:
chan <- PTTrack(rep("C-3 01 C20", 64))

data("mod.intro")

## This will replace the PTTrack at pattern
## number 1, track number 2 of mod.intro with chan:
PTTrack(mod.intro, 2, 1) <- chan


ProTrackR documentation built on Aug. 23, 2023, 1:07 a.m.