moffset | R Documentation |

Modify a matrix by shifting successive elements.

```
moffset(mat, roffset = 0, coffset = 0, postfix = "",
rprefix = "Row.", cprefix = "Col.")
```

`mat` |
Data frame or matrix.
This ought to have at least three rows and three columns.
The elements are shifted in the order of |

`roffset, coffset` |
Numeric or character.
If numeric, the amount of shift (offset) for each row and column.
The default is no change to |

`postfix` |
Character. Modified rows and columns are renamed by pasting this argument to the end of each name. The default is no change. |

`rprefix, cprefix` |
Same as |

This function allows a matrix to be rearranged so that
element (`roffset`

+ 1, `coffset`

+ 1)
becomes the (1, 1) element.
The elements are assumed to be ordered in the same way
as the elements of `c(mat)`

,

This function is applicable to, e.g.,
`alcoff`

,
where it is useful to define the *effective day*
as starting
at some other hour than midnight, e.g., 6.00am.
This is because partying on Friday night continues on into
Saturday morning, therefore it is more interpretable to use
the effective day when considering a daily effect.

This is a data preprocessing function for `rcim`

and `plotrcim0`

. The differences between
`Rcim`

and `moffset`

is that
`Rcim`

only reorders the level of the
rows and columns
so that the data is shifted but not moved.
That is, a value in one row stays in that row,
and ditto for column.
But in `moffset`

values in one column can be moved to a previous column.
See the examples below.

A matrix of the same dimensional as its input.

The input `mat`

should have row names and column names.

T. W. Yee, Alfian F. Hadi.

`Rcim`

,
`rcim`

,
`plotrcim0`

,
`alcoff`

,
`crashi`

.

```
# Some day's data is moved to previous day:
moffset(alcoff, 3, 2, "*")
Rcim(alcoff, 3 + 1, 2 + 1) # Data does not move as much.
alcoff # Original data
moffset(alcoff, 3, 2, "*") -
Rcim(alcoff, 3+1, 2+1) # Note the differences
# An 'effective day' data set:
alcoff.e <- moffset(alcoff, roffset = "6", postfix = "*")
fit.o <- rcim(alcoff) # default baselines are 1st row and col
fit.e <- rcim(alcoff.e) # default baselines are 1st row and col
## Not run: par(mfrow = c(2, 2), mar = c(9, 4, 2, 1))
plot(fit.o, rsub = "Not very interpretable",
csub = "Not very interpretable")
plot(fit.e, rsub = "More interpretable",
csub = "More interpretable")
## End(Not run)
# Some checking
all.equal(moffset(alcoff), alcoff) # Should be no change
moffset(alcoff, 1, 1, "*")
moffset(alcoff, 2, 3, "*")
moffset(alcoff, 1, 0, "*")
moffset(alcoff, 0, 1, "*")
moffset(alcoff, "6", "Mon", "*") # This one is good
# Customise row and column baselines
fit2 <- rcim(Rcim(alcoff.e, rbaseline = "11", cbaseline = "Mon*"))
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.