>
> So in this example, it seems more efficient to sort first and use the
> algorithm assuming that the data is sorted.
>
> There is probably a way to be smarter in nodup_cpp where the bottleneck
> is likely to be related to map::find.
If you just use a hash table, std::map should work too,
I d
) )[oo] } )
utilisateur système écoulé
0.251 0.011 0.262
> system.time( { oo <- order(order(x)) ; nodup4( sort( x ) )[oo] } )
utilisateur système écoulé
0.287 0.006 0.294
Romain
Le 26/11/10 20:01, William Dunlap a écrit :
-Original Message-
From: William Dunlap
Sent: Thursday, Nov
Thanks guys, the "rle" function works pretty well. Thank you all for the
efforts.
Zheng
--
View this message in context:
http://r.789695.n4.nabble.com/help-program-efficiency-tp3059079p3061103.html
Sent from the R help mailing list archive at Nabble.com.
___
> Date: Fri, 26 Nov 2010 11:25:26 -0800
> From: roman.lust...@gmail.com
> To: r-help@r-project.org
> Subject: Re: [R] help: program efficiency
>
>
> Oops, tiny mistake. Try
>
> lapply(X = b, FUN = function(x) {
>
7 0.006 0.294
Romain
Le 26/11/10 20:01, William Dunlap a écrit :
-Original Message-
From: William Dunlap
Sent: Thursday, November 25, 2010 9:31 AM
To: 'randomcz'; r-help@r-project.org
Subject: RE: [R] help: program efficiency
If the input vector t is known to be
r:
> x <- c( 2, 1, 1, 2 )
> nodup4( sort( x ) )
[1] 1.00 1.01 2.00 2.01
> nodup_cpp( x )
[1] 2.00 1.00 1.01 2.01
Romain
Le 26/11/10 20:01, William Dunlap a écrit :
-Original Message-
From: William Dunlap
Sent: Thursday, November 25, 2010 9:31 AM
To: 'randomcz'; r-he
Oops, tiny mistake. Try
lapply(X = b, FUN = function(x) {
swn <- seq(from = 0, to = (0 + 0.01*length(x))-0.01, by
= 0.01)
out <- x + swn
return(out)
})
--
View this message in context:
http://r.789695.n4.na
See if this works for you.
a <- c(2,1,1,3,3,3,4)
a.fac <- as.factor(a)
b <- split(a, f = a.fac)
system.time(lapply(X = b, FUN = function(x) {
swn <- seq(from = 0, to = 0 + 0.01*length(x), by = 0.01)
out <- x + swn
return(out)
> -Original Message-
> From: William Dunlap
> Sent: Thursday, November 25, 2010 9:31 AM
> To: 'randomcz'; r-help@r-project.org
> Subject: RE: [R] help: program efficiency
>
> If the input vector t is known to be ordered
> (or if you only care about ru
> Date: Thu, 25 Nov 2010 06:49:19 -0800
> From: rando...@gmail.com
> To: r-help@r-project.org
> Subject: [R] help: program efficiency
>
>
> hey guys,
>
> I am working on a function to make a duplicated value unique. For exa
cz
> Sent: Thursday, November 25, 2010 6:49 AM
> To: r-help@r-project.org
> Subject: [R] help: program efficiency
>
>
> hey guys,
>
> I am working on a function to make a duplicated value unique.
> For example,
> the original vector would be like : a = c(2,1,
one way is the following:
a <- c(2,1,1,3,3,3,4)
d <- unlist(sapply(rle(a)$length, function (x)
if (x > 1) seq(0.01, by = 0.01, len = x) else 0))
a + d
I hope it helps.
Best,
Dimitris
On 11/25/2010 3:49 PM, randomcz wrote:
hey guys,
I am working on a function to make a duplicated val
hey guys,
I am working on a function to make a duplicated value unique. For example,
the original vector would be like : a = c(2,1,1,3,3,3,4)
I'll like to transform it into:
a.nodup = 2, 1.01, 1.02, 3.01, 3.02, 3.03, 4
basically, find the duplicates and assign a unique value by adding a small
amo
13 matches
Mail list logo