[R] Analog to matlab repmat function

From: Daniil Ivanov <daniil.ivanov_at_gmail.com>
Date: Mon 29 May 2006 - 21:04:45 EST

Thanks a lot to all of you!

 Now I see, that use of R (and S) is very different from use of Matlab.  There is no one-to-one correspondence.
 I'm shy to ask so stupid questions, but name of language R  makes it hard to find relevant links trough google.  Thanks for pointing to "S Poetry", I would never find it alone,  since I was looking for R-related info.

Thanks, Daniil.

On 5/29/06, Patrick Burns <pburns@pburns.seanet.com> wrote:
> S Poetry may be of use to you.
>
>
> Patrick Burns
> patrick@burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S User")
>
> Daniil Ivanov wrote:
>
> >Hello,
> >
> > I'm trying to switch from Matlab to R-project, and having some difficulties.
> > I make a use of multidimensional matrices. For example, I need to extract
> > mean from one of the dimensions:
> >
> > % we have matrix data of size: 130 x 11 x 350 x 2
> > data = data - repmat(mean(data,3),[130 1 1 1]);
> >
> > In R project I managed to do that in a very pervarsive way:
> >
> > # mean(data,3) in R
> > base <- apply(data,c(2,3,4),mean)
> > # repmat(...,[130 1 1 1])
> > base <- rep(base,130)
> > dim(base) <- c(11,2,350,130)
> > base <- aperm(base,c(4,1,2,3))
> > # data = data - repmat
> > data <- data - base;
> >
> > Could you please show me a more elegant way of doing the same in R :)
> >
> >Thanks, Daniil.
> >
> >______________________________________________
> >R-help@stat.math.ethz.ch mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >
> >
> >
> >
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon May 29 22:18:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 30 May 2006 - 00:10:24 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.