Mark,
That has to do with how operators bind and their precedence.
> Date: Thu, 11 Oct 2007 15:34:22 -0400
> From: "Leeds, Mark (IED)" <[EMAIL PROTECTED]>
> Sender: [EMAIL PROTECTED]
> Importance: normal
> Priority: normal
> Precedence: list
> Thread-topic: confusion with R syntax
> Thread-ind
On 10/11/07, Leeds, Mark (IED) <[EMAIL PROTECTED]> wrote:
> thanks to all for your explanations. It seems like, because it's done
> sequentially, you can put as many [] on as
> you like as long as they make sense. It probably was a bad question but
> this concept is quite different
> from C which i
Mark
-Original Message-
From: Gabor Grothendieck [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 11, 2007 4:26 PM
To: Andrew Robinson
Cc: Leeds, Mark (IED); [EMAIL PROTECTED]
Subject: Re: [R] confusion with R syntax
Or with
x <- 1:10
# these are all the same
x[2:4][1]
(x[2:4])[1]
y <
It is not 2 dimensional indexing, but 1 dimensional indexing done twice.
Would this surprise you?:
> x <- 1:10
> y <- x[2:4]
> y[ c(TRUE,FALSE,TRUE) ]
[1] 2 4
Because your code is just the same (skipping the intermediate y step).
You start with x, then apply a subscripting argument to that grab
Or with
x <- 1:10
# these are all the same
x[2:4][1]
(x[2:4])[1]
y <- x[2:4]
y[1]
On 10/11/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
> Hi Mark,
>
> what's happening here is that R is applying the one-dimensional
> subscripting operations sequentially.
>
> Try
>
> x <- seq(1,10)
> x[2:4][
On 11/10/2007, Leeds, Mark (IED) <[EMAIL PROTECTED]> wrote:
> I just noticed something by accident with R syntax that I'm sure is
> correct but I don't understand it. If I have
> a simple numeric vector x and I subscript it, it seems that I can then
> subscript a second time with TRUE
> or FALSE, s
Leeds, Mark (IED) wrote:
> I just noticed something by accident with R syntax that I'm sure is
> correct but I don't understand it. If I have
> a simple numeric vector x and I subscript it, it seems that I can then
> subscript a second time with TRUE
> or FALSE, sort of like a 2 dimensional array i
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Leeds, Mark (IED)
> Sent: Thursday, October 11, 2007 12:34 PM
> To: [EMAIL PROTECTED]
> Subject: [R] confusion with R syntax
>
> I just noticed something by accident with R syntax that I'm sure is
> co
Hi Mark,
what's happening here is that R is applying the one-dimensional
subscripting operations sequentially.
Try
x <- seq(1,10)
x[2:4][1]
Cheers
Andrew
On Thu, Oct 11, 2007 at 03:34:22PM -0400, Leeds, Mark (IED) wrote:
> I just noticed something by accident with R syntax that I'm sure is
>
9 matches
Mail list logo