mrguilfoyle at gmail.com
Mon Mar 6 22:10:33 CET 2017
Effectively you want a circulant matrix but filled by column.
Example input vector and number of columns
x = c(1:8,19:20)
nc = 5
For the result you specifically describe, the following generalises for any vector and any arbitrary number of columns 'nc', padding with zeros as necessary.
For the unpadded column circulant on the same inputs
nx = length(x)
ind = 1+ outer(0:(nx-1),0:(1-nc),'+') %% nx
> On 6 Mar 2017, at 16:18, Peter Thuresson <peter.thuresson at umea.se> wrote:
> Is there a function in R which can transform, let say a vector:
> to a matrix where the vector is repeated but "projected" +1 one step down for every (new) column.
> I want the output below from the vector above, like this:
> best regards / Peter
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help