subset() of a vector in R

后端 未结 2 1540
鱼传尺愫
鱼传尺愫 2021-02-06 10:45

I\'ve written the following function based on subset(), which I find handy:

ss <- function (x, subset, ...) 
{
    r <- eval(substitute(subset         


        
2条回答
  •  自闭症患者
    2021-02-06 10:55

    I realize that the solution Ken offers is more general than just selecting items within ranges (since it should work on any logical expression) but this did remind me that Greg Snow has comparison infix operators in his Teaching Demos package:

    library(TeachingDemos)
    x0 <- rnorm(100)
    x0[ 0 %<% x0 %<% 1.5 ]
    

提交回复
热议问题