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 in C. Does someone know if
this is
-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
correct
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 in C.
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
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, sort of
To: [EMAIL PROTECTED]
Subject: [R] confusion with R syntax
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
-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 - x[2:4]
y[1
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 is
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-index
9 matches
Mail list logo