I'm new in pipes R. I have a dataframe like this
library(magrittr)
library(dplyr)
df = data.frame(a= c(1,2,3,4,5), b = c(3,4,5,6,7))
The result is
df_min = df %>% filter(a > 2) %$% as.data.frame( cbind(a=a*10, b))
> df_min
a b
1 30 5
2 40 6
3 50 7
Is there is a more convinient and shorter way instead of %$% as.data.frame( cbind(a=a*10, b))
?
A shorter option with data.table
library(data.table)
setDT(df)[a > 2, .(a = a * 10, b)]