Hello Markus,

On 6/27/07, Markus Loecher <loecher@eden.rutgers.edu> wrote:
>
> Dear list members,
> I use both R and Matlab and find that each has its own strengths. Matlab
> definitely has the edge when it comes to the interactivity of its graphs.


I also use both. R definitely has the edge when it comes to do perform
statistical data analyses :)
(and also when you consider the price...)

In addition I find the little operator end extremely useful in indexing
> arrays. (as in x(1:end,) )


You mean 'x(1:end,1:end)' or 'x(:,:)'  (':' is equivalent to "1:end")

When I go from R to Matlab, I tend to forget to type the ':' ("a[,2]" in R
is "a(:,2)" in Matlab.)

The interest of 'end' is clearer when the starting index is larger than 1 as
in, e.g., 'x(2:end)'

Yet note that in R, you can use negative indexes:

  x[-1]   is the R equivalent of  Matlab's x(2:end)

  x[-(1:(n-1))] is equivalent to x(n:end)


I agree that R syntax may be a bit less "elegant" in this particular
situation (but try to write the equivalent of a[-2,] in Matlab)
Personally, I would stick to "x[n:length(x)]" (or "a[n:nrow(a),]" for a
matrix). Anyway this kind of code would probably appear inside a loop and I
would put the numbers of rows or columns in variables if there are needed
more than once.

Best,

-- 
Christophe Pallier

	[[alternative HTML version deleted]]

