Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Laurent Rhelp
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

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Laurent Rhelp
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

Re: [R-es] Consulta filtro múltiple.

2021-07-05 Thread juan manuel dias
Hola, como andan! Estaba trabajando nuevamente con estoy pensaba que teniendo un data frame por separado con las monodrogas y unidades que tengo que filtrar, lo podría resolver con un simple inner join de dplyr. prueba_2<-base_precios_jun_2021_final %>% inner_join(mono_unid) view(prueba_2)

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread David Winsemius
> 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, >

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Laurent Rhelp
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

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Laurent Rhelp
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

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Jeff Newmiller
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 )),

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Laurent Rhelp
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 )) > >

Re: [R] Some difficulties to use the apply command on an array

2021-07-05 Thread Eric Berger
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

[R] Some difficulties to use the apply command on an array

2021-07-05 Thread Laurent Rhelp
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.5242834298729342+0i,   10.304766710160479+0i,