It is good trick and we have to know that R arrays use the 'column major
mode' to store the value.
Thank you
Laurent
Le 05/07/2021 à 19:03, David Winsemius a écrit :
On Jul 5, 2021, at 7:56 AM, Laurent Rhelp wrote:
Dear R-Help,
I have an array x made up of three matrices of 5 rows and 3 c
Very interesting
Thank you
Le 05/07/2021 à 17:31, Jeff Newmiller a écrit :
apply _always_ returns a matrix of vector results. That is, the result of each
call to FUN may be a matrix, but a matrix is merely a vector with dimensions
that are in this case ignored. So restore the dimensions on th
> On Jul 5, 2021, at 7:56 AM, Laurent Rhelp wrote:
>
> Dear R-Help,
>
> I have an array x made up of three matrices of 5 rows and 3 columns of
> complex numbers (the complex numbers are not the problem)
>
> ## my array
> x <- structure(c(5.6196790161893828+0i, 5.7565523942393364+0i,
> 8.52
ok, I use the R version 4.0.3
I have to upgrade my version
https://developer.r-project.org/blosxom.cgi/R-devel/NEWS/2021/03/06#n2021-03-06
Le 05/07/2021 à 17:05, Andrew Simmons a écrit :
> Hello,
>
>
> It seems as though you may be using `MARGIN` incorrectly. `MARGIN` is
> the indices you are
Thank you for the explanations. Indeed I made a mistake for the MARGIN
understanding. But when I use the command I have an error because there
is no simplify argument in the apply command ?
Le 05/07/2021 à 17:05, Andrew Simmons a écrit :
> Hello,
>
>
> It seems as though you may be using `MAR
apply _always_ returns a matrix of vector results. That is, the result of each
call to FUN may be a matrix, but a matrix is merely a vector with dimensions
that are in this case ignored. So restore the dimensions on the result:
array(apply(x, 1, FUN = function(x) diag( svd(x)$d )), dim=c(3,3,5))
Thank you very much Eric, I did not think to use lapply.
Le 05/07/2021 à 17:15, Eric Berger a écrit :
> Hi Laurent,
> I am not sure how to get apply() to work but the following uses
> lapply() and returns the matrices in a list.
>
> lapply(1:3, FUN = function(i) diag( svd(x[i,,])$d ))
>
> HTH
Hi Laurent,
I am not sure how to get apply() to work but the following uses lapply()
and returns the matrices in a list.
lapply(1:3, FUN = function(i) diag( svd(x[i,,])$d ))
HTH,
Eric
On Mon, Jul 5, 2021 at 5:56 PM Laurent Rhelp wrote:
> Dear R-Help,
>
> I have an array x made up of three mat
8 matches
Mail list logo