[R] Subsetting a vector of numerics such that standard deviation is less than 0.5 ?

Dimitri Liakhovitski ld7631 at gmail.com
Wed Apr 22 16:58:29 CEST 2009


Daren,
what are you trying to achieve?
Why don't you want any negative numbers?
Anyway, if you only need positive values, why not:
set.seed(999)
v<-rnorm(20,mean=2,sd=0.5)
(v)
(sd(v))

Dimitri

On Wed, Apr 22, 2009 at 1:26 AM, Daren Tan <darentan76 at gmail.com> wrote:
>> set.seed(999)
>> abs(rnorm(20))
>  [1] 0.28174016 1.31255963 0.79518398 0.27007049 0.27730642 0.56602374
> 1.87865826 1.26679114 0.96774968 1.12100936 1.32546371 0.13397739
> 0.93874945
> [14] 0.17253810 0.95765045 1.36268625 0.06833513 0.10065765 0.90134475
> 2.07435711
>> v <- abs(rnorm(20))
>> v
>  [1] 1.2285633 0.6430443 0.3597629 0.2940356 1.1252685 0.6422657
> 1.1067376 0.8848404 1.5540951 0.1266790 2.3826642 0.6012761 0.1793613
> 1.0805315 0.2468121
> [16] 2.1137370 0.3705275 0.5228678 0.5178055 1.4025109
>
> How do I select numbers from v such that the standard deviation of the
> new vector is less than 0.5 ?
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Dimitri Liakhovitski
MarketTools, Inc.
Dimitri.Liakhovitski at markettools.com




More information about the R-help mailing list