Hello,
Since no one took the bait, I've written some C code and run some tests.
The tests are divided in two parts, one uses a random vector 'x', the
other makes sure the condition will only be met at the end.v See below.
But first
1. Like Bert said, now your data. I've tested Milan's code, n
On Thu, Sep 20, 2012 at 4:39 PM, Mike Spam wrote:
> Thank you very much, especially Milan and Bert!
> I will do some speedtests and fit the function to my needs.
>
> I think the best way would be a modified function in C...
> But i am not familiar enough with C. Perhaps this would be a simple
> bu
é
>> 14.288 9.510 24.562
>>> system.time(for(i in 1:100)find(x, .999))
>> utilisateur système écoulé
>> 0.017 0.002 0.019
>>> find(x, .999)
>> [1] 1376
>>
>> (Looks almost like cheating... ;-)
Excellent point! Thanks.
-- Bert
On Wed, Sep 19, 2012 at 12:00 PM, Berend Hasselman wrote:
>
> On 19-09-2012, at 20:02, Bert Gunter wrote:
>
>> Well, following up on this observation, which can be put under the
>> heading of "Sometimes vectorization can be much slower than explicit
>> loops" , I
On 19-09-2012, at 20:02, Bert Gunter wrote:
> Well, following up on this observation, which can be put under the
> heading of "Sometimes vectorization can be much slower than explicit
> loops" , I offer the following:
>
> firsti <-function(x,k)
> {
> i <- 1
> while(x[i]<=k){i <- i+1}
> i
> }
999)
> [1] 1376
>
> (Looks almost like cheating... ;-)
>
>
>
>
>
>> Bill Dunlap
>> Spotfire, TIBCO Software
>> wdunlap tibco.com
>>
>>
>> > -Original Message-
>> > From: r-help-boun...@r-project.org [mailto:r-he
t; > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> > Behalf
> > Of Jeff Newmiller
> > Sent: Wednesday, September 19, 2012 8:06 AM
> > To: Mike Spam; r-help@r-project.org
> > Subject: Re: [R] effective way to return only the first argum
nt: Wednesday, September 19, 2012 8:06 AM
> To: Mike Spam; r-help@r-project.org
> Subject: Re: [R] effective way to return only the first argument of "which()"
>
> ?which.max
> ---
> Jeff Newmil
Hi,
Thanks Michael, but i think this is even slower.
x <-sample(2000)
which(x < 5)[1]
which.max(x < 5)
system.time(for(i in 1:100) which.max(x < 5))
User System verstrichen
60.84 13.70 86.33
system.time(for(i in 1:100) which(x < 5)[1])
User Syste
?which.max
---
Jeff NewmillerThe . . Go Live...
DCN:Basics: ##.#. ##.#. Live Go...
Live: OO#.. Dead: OO#.. Playing
Research Engi
On Wed, Sep 19, 2012 at 3:20 PM, Mike Spam wrote:
> Hi,
>
> I was looking for a function like "which()" but only returns the first
> argument.
> Compare:
>
> x <- c(1,2,3,4,5,6)
> y <- 4
> which(x>y)
>
> returns:
> 5,6
>
> which(x>y)[1]
> returns:
> 5
>
> which(x>y)[1] is exactly what i need. I d
Hi,
I was looking for a function like "which()" but only returns the first argument.
Compare:
x <- c(1,2,3,4,5,6)
y <- 4
which(x>y)
returns:
5,6
which(x>y)[1]
returns:
5
which(x>y)[1] is exactly what i need. I did use this but the dataset
is too big (~18 mio. Points).
That's why i need a more
12 matches
Mail list logo