On Fri, Dec 12, 2008 at 3:08 PM, Vitalie Spinu wrote:
> On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham
> wrote:
>
>
>>> or may be just
>>> mtcars[cyl>3&last(20)]
>>>
>>> or this is already too far?
>>
>> This would be a considerable extension because then the selector would
>> need to know ab
On Fri, 12 Dec 2008 18:27:02 +0100, hadley wickham wrote:
or may be just
mtcars[cyl>3&last(20)]
or this is already too far?
This would be a considerable extension because then the selector would
need to know about all other variables in the dataset, and you'd need
someway of combining selec
> My end would be the output of your end(). If there are no args and no local
> context, I don't see the need for it to be a function call. It would just
> be defined as something like
>
> end <- structure( function(n) c(rep(FALSE, n-1), TRUE), class="selector")
Oh, I see what you mean.
> I'm n
; project.org] On Behalf Of Claudia Beleites
> Sent: Friday, December 12, 2008 11:38 AM
> To: r-help@r-project.org
> Subject: Re: [R] The end of Matlab
>
> > evens() & last(5)
> wouldn't x[evens()][last(5)] do the & already?
>
> or is different, though.
>
> evens() & last(5)
wouldn't x[evens()][last(5)] do the & already?
or is different, though.
Claudia
--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste
phone: +39 (0 40) 5 58-34 47
email: cbelei...@un
On 12/12/2008 1:06 PM, hadley wickham wrote:
Oh yes, that's a good point. But wouldn't the following do the job?
"&.selector" <- function(a, b) {
function(n) a(n) & b(n)
}
or
"&.selector" <- function(a, b) {
function(n) intersect(a(n), b(n))
}
depending on whether selectors return logical
>> Oh yes, that's a good point. But wouldn't the following do the job?
>>
>> "&.selector" <- function(a, b) {
>> function(n) a(n) & b(n)
>> }
>>
>> or
>>
>> "&.selector" <- function(a, b) {
>> function(n) intersect(a(n), b(n))
>> }
>>
>> depending on whether selectors return logical or numeric v
On 12/12/2008 12:23 PM, hadley wickham wrote:
On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch wrote:
On 12/12/2008 11:38 AM, hadley wickham wrote:
On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch
wrote:
On 12/12/2008 8:25 AM, hadley wickham wrote:
From which you might conclude that I don
On Fri, Dec 12, 2008 at 12:11 PM, Vitalie Spinu wrote:
> On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham
> wrote:
>
>> You could also imagine similar iterators for random sampling, like
>> samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
>> with replacement. first(n) could a
On Fri, Dec 12, 2008 at 11:11 AM, Vitalie Spinu wrote:
> On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham
> wrote:
>
>> You could also imagine similar iterators for random sampling, like
>> samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
>> with replacement. first(n) could a
On Fri, Dec 12, 2008 at 11:18 AM, Duncan Murdoch wrote:
> On 12/12/2008 11:38 AM, hadley wickham wrote:
>>
>> On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch
>> wrote:
>>>
>>> On 12/12/2008 8:25 AM, hadley wickham wrote:
>
> From which you might conclude that I don't like the design of su
On 12/12/2008 11:38 AM, hadley wickham wrote:
On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch wrote:
On 12/12/2008 8:25 AM, hadley wickham wrote:
From which you might conclude that I don't like the design of subset, and
you'd be right. However, I don't think this is a counterexample to my
ge
On Fri, 12 Dec 2008 17:38:13 +0100, hadley wickham wrote:
You could also imagine similar iterators for random sampling, like
samp(0.2) to choose 20% of the indices, or boot(0.8) to choose 80%
with replacement. first(n) could also be useful, selecting the first
min(n, length(vector)) observatio
On Fri, Dec 12, 2008 at 8:41 AM, Duncan Murdoch wrote:
> On 12/12/2008 8:25 AM, hadley wickham wrote:
>>>
>>> From which you might conclude that I don't like the design of subset, and
>>> you'd be right. However, I don't think this is a counterexample to my
>>> general rule. In the subset functi
k
> Sent: Friday, December 12, 2008 8:57 AM
> To: claudia.belei...@gmx.de
> Cc: R help
> Subject: Re: [R] The end of Matlab
>
> Claudia Beleites wrote:
> >>> Wacek:
> >>>
> >>>> x[3:]
> >>>> instead of
> >>>&g
Claudia Beleites wrote:
>>> Wacek:
>>>
x[3:]
instead of
x[3:length(x)]
x[3:end]
>>> I don't think that would help:
>>> what to use for end - 3 within the convention that negative values mean
>>> exclusion?
>>>
>> might seem tricky, but not impossible:
I just realized that my idea of doing something without going into the
extraction functions itself won't work
:-( it was a nice dream, though.
The reason is that there is no general way to find out what the needed length
is: At least I'm just writing a class where 2 kinds of columns are involve
Here is how to emulate matlab end in R in the case of matrices.
Rather than redefine the matrix class (which would be a bit intrusive) we
just define a subclass of matrix called matrix2. Note in the examples that
matrix2 survives some operations such as + but not others such as crossprod
so in th
> > Wacek:
> >> x[3:]
> >> instead of
> >> x[3:length(x)]
> >> x[3:end]
> >
> > I don't think that would help:
> > what to use for end - 3 within the convention that negative values mean
> > exclusion?
>
> might seem tricky, but not impossible:
>
> x[-2]
> # could mean 'all except for 2nd', as it i
>> Wacek:
>>
>>
>>> x[3:]
>>> instead of
>>> x[3:length(x)]
>>> x[3:end]
>>>
>>>
>> I don't think that would help:
>> what to use for end - 3 within the convention that negative values mean
>> exclusion?
>>
>>
>>
>>
>
> might seem tricky, but not impossible:
>
> x[-2]
On 12/12/2008 8:25 AM, hadley wickham wrote:
From which you might conclude that I don't like the design of subset, and
you'd be right. However, I don't think this is a counterexample to my
general rule. In the subset function, the select argument is treated as an
unevaluated expression, and the
Claudia Beleites wrote:
> Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
>
>> How about:
>>
>> x[, -seq(to=ncol(x), length=n)]
>>
> Doing it is not my problem. I just agree with Mike in that I would like if I
> could do shorter than:
>
> x[, 1 : (ncol(x) - n)]
>
> which I bt
Am Freitag 12 Dezember 2008 13:10:20 schrieb Patrick Burns:
> How about:
>
> x[, -seq(to=ncol(x), length=n)]
Doing it is not my problem. I just agree with Mike in that I would like if I
could do shorter than:
x[, 1 : (ncol(x) - n)]
which I btw prefer to your solution.
Also, I don't have a pro
> From which you might conclude that I don't like the design of subset, and
> you'd be right. However, I don't think this is a counterexample to my
> general rule. In the subset function, the select argument is treated as an
> unevaluated expression, and then there are rules about what to do with
Duncan Murdoch wrote:
> On 11/12/2008 9:45 PM, Mike Rowe wrote:
>
>>
>> this.matrix[3:end,end]
>>
>> would be equivalent to:
>>
>> this.matrix[3:nrow(this.matrix),ncol(this.matrix)] # or
>> this.matrix[3:dim(this.matrix)[1],dim(this.matrix)[2]]
>>
>> As you can see, the R version requires more ty
How about:
x[, -seq(to=ncol(x), length=n)]
Patrick Burns
patr...@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")
Claudia Beleites wrote:
Dear list,
Learning to use the power of R's indexing and functios like head() an
Dear list,
> Learning to use the power of R's indexing and functios like head() and
> tail() (which are just syntactic sugar) will probably lead you not to miss
> this.
However, how do I exclude the last columns of a data.frame or matrix (or, in
general, head and tail for given dimensions of an a
Duncan Murdoch wrote:
> On 12/12/2008 3:41 AM, Wacek Kusnierczyk wrote:
>>
>> but this 'general rule' is not really adhered to in r! one example
>> already discussed here at length is subset:
>>
>> subset(data.frame(...), select=a)
>>
>> what will be selected? column named "a", or columns named b
On 12/12/2008 3:41 AM, Wacek Kusnierczyk wrote:
Duncan Murdoch wrote:
On 11/12/2008 9:45 PM, Mike Rowe wrote:
Greetings!
I come to R by way of Matlab. One feature in Matlab I miss is its
"end" keyword. When you put "end" inside an indexing expression, it
is interpreted as the length of the v
On Fri, 12 Dec 2008, Duncan Murdoch wrote:
On 11/12/2008 9:45 PM, Mike Rowe wrote:
Greetings!
I come to R by way of Matlab. One feature in Matlab I miss is its
"end" keyword. When you put "end" inside an indexing expression, it
is interpreted as the length of the variable along the dimension
Duncan Murdoch wrote:
> On 11/12/2008 9:45 PM, Mike Rowe wrote:
>> Greetings!
>>
>> I come to R by way of Matlab. One feature in Matlab I miss is its
>> "end" keyword. When you put "end" inside an indexing expression, it
>> is interpreted as the length of the variable along the dimension being
>>
On 11/12/2008 9:45 PM, Mike Rowe wrote:
Greetings!
I come to R by way of Matlab. One feature in Matlab I miss is its
"end" keyword. When you put "end" inside an indexing expression, it
is interpreted as the length of the variable along the dimension being
indexed. For example, if the same fea
Its been pointed out to me that the second one is wrong.
It should be:
tail(this.matrix, -2)[, ncol(this.matrix)]
which is not as compact as matlab or my prior post but
still not particularly onerous.
On Thu, Dec 11, 2008 at 11:49 PM, Gabor Grothendieck
wrote:
> Use tail and head. See interspe
Use tail and head. See interspersed.
On Thu, Dec 11, 2008 at 9:45 PM, Mike Rowe wrote:
> Greetings!
>
> I come to R by way of Matlab. One feature in Matlab I miss is its
> "end" keyword. When you put "end" inside an indexing expression, it
> is interpreted as the length of the variable along th
Greetings!
I come to R by way of Matlab. One feature in Matlab I miss is its
"end" keyword. When you put "end" inside an indexing expression, it
is interpreted as the length of the variable along the dimension being
indexed. For example, if the same feature were implemented in R:
my.vector[5:e
35 matches
Mail list logo