For example let's be a vector ttt <- c(1,5,7,2,6) and suppose that we want a vector with ttt's elements bigger than 2. Then we have to write ttt[ttt>2].
ttt <- c(1,5,7,2,6)
ttt
ttt[ttt>2]
Can we have a function TF_sequense(,), witch does this thing by writing TF_sequense(ttt,>2)?
TF_sequense(,)
TF_sequense(ttt,>2)
I tried do.call() function from this question, but I couldn't find a solution.
do.call()
Thanks in advance!
We can use
TF_sequence <- function(vec, expr) { obj1 <- deparse(substitute(vec)) eval(parse(text = sprintf("%s[%s%s]", obj1, obj1, expr))) } TF_sequence(ttt, ">2")
1.4m articles
1.4m replys
5 comments
57.0k users