Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

process

Force index arrays into range


Description

Forces an (integer) array to have entries in the range 1-n, by (i) taking the entries modulo n, then (ii) setting zero elements to n. Useful for modifying index arrays into a form suitable for use with magic squares.

Usage

process(x, n)

Arguments

x

Index array to be processed

n

Modulo of arithmetic to be used

Author(s)

Robin K. S. Hankin

Examples

# extract the broken diagonal of magic.2np1(4) that passes
# through element [1,5]:

a <- magic.2np1(4)
index <- t(c(1,5)+rbind(1:9,1:9))
a[process(index,9)]

magic

Create and Investigate Magic Squares

v1.5-9
GPL-2
Authors
Robin K. S. Hankin
Initial release
2018-09-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.