0 NA Inf0
[2,] Inf0 NA Inf0 NA
[3,]0 NA Inf0 NA Inf
[4,] NA Inf0 NA Inf0
> mat2vec(myNA)
[1] NA Inf 0 NA Inf 0 NA Inf 0 NA Inf 0 NA Inf 0
[16] NA Inf 0 NA Inf 0 NA Inf 0
> myvec <- 1:8
> mat2vec(myvec)
[1] 1 2 3 4 5 6
You could use a for loop in a brute force approach.
-Original Message-
From: R-help On Behalf Of Rui Barradas
Sent: Sunday, August 6, 2023 7:37 PM
To: Iris Simmons ; Steven Yen
Cc: R-help Mailing List
Subject: Re: [R] Stacking matrix columns
[External Email]
Às 01:15 de 06/08/2023
Às 01:15 de 06/08/2023, Iris Simmons escreveu:
You could also do
dim(x) <- c(length(x), 1)
On Sat, Aug 5, 2023, 20:12 Steven Yen wrote:
I wish to stack columns of a matrix into one column. The following
matrix command does it. Any other ways? Thanks.
> x<-matrix(1:20,5,4)
> x
[,1
st a vector with a bonus.
-Original Message-
From: R-help On Behalf Of Steven Yen
Sent: Saturday, August 5, 2023 8:08 PM
To: R-help Mailing List
Subject: [R] Stacking matrix columns
I wish to stack columns of a matrix into one column. The following
matrix command does it. Any other wa
Sent: Sunday, August 6, 2023 11:59 AM
To: avi.e.gr...@gmail.com
Cc: R-help Mailing List
Subject: Re: [R] Stacking matrix columns
Avi,
I was not trying to provide the most economical solution. I was trying
to anticipate that people (either the OP or others searching for how
to stack columns of a
er answer.
>
> -Original Message-
> From: R-help On Behalf Of Eric Berger
> Sent: Sunday, August 6, 2023 3:34 AM
> To: Bert Gunter
> Cc: R-help Mailing List ; Steven Yen
> Subject: Re: [R] Stacking matrix columns
>
> Stacking columns of a matrix is a standard operatio
, 2023 3:34 AM
To: Bert Gunter
Cc: R-help Mailing List ; Steven Yen
Subject: Re: [R] Stacking matrix columns
Stacking columns of a matrix is a standard operation in multilinear
algebra, usually written as the operator vec().
I checked to see if there is an R package that deals with multilinear
I wish to stack columns of a matrix into one column. The following
matrix command does it. Any other ways? Thanks.
> x<-matrix(1:20,5,4)
> x
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
> ma
Stacking columns of a matrix is a standard operation in multilinear
algebra, usually written as the operator vec().
I checked to see if there is an R package that deals with multilinear
algebra. I found rTensor, which has a function vec().
So, yet another way to accomplish what you want would be:
Or just dim(x) <- NULL.
(as matrices in base R are just vectors with a dim attribute stored in
column major order)
ergo:
> x
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
> x<- 1:20 ## a vector
> is.matrix(x)
[1] FALSE
> dim(x) <- c(5,4)
> is.matrix(x)
[1] TRUE
> attributes(x)
you make the matric
by rows as in:
-Original Message-
From: R-help On Behalf Of Steven Yen
Sent: Saturday, August 5, 2023 8:11 PM
To: R-help Mailing List
Subject: [R] Stacking matrix columns
I wish to stack columns of a matrix into one column. The following
matrix command does it. Any o
You could also do
dim(x) <- c(length(x), 1)
On Sat, Aug 5, 2023, 20:12 Steven Yen wrote:
> I wish to stack columns of a matrix into one column. The following
> matrix command does it. Any other ways? Thanks.
>
> > x<-matrix(1:20,5,4)
> > x
> [,1] [,2] [,3] [,4]
> [1,]16 11 1
I wish to stack columns of a matrix into one column. The following
matrix command does it. Any other ways? Thanks.
> x<-matrix(1:20,5,4)
> x
[,1] [,2] [,3] [,4]
[1,] 1 6 11 16
[2,] 2 7 12 17
[3,] 3 8 13 18
[4,] 4 9 14 19
[5,] 5 10 15 20
> ma
13 matches
Mail list logo