如何使用说明管道 (%$%) 运算符在 R 中串接两个函数
How to string two functions in R with an exposition piping (%$%) operator
我想结合这两个功能:
`dataframe %$%
t.test(vector1, vector2, paired = T)
dataframe %$%
cohen.d.(vector1, vector2, paired = T)`
变成只需要 data.frame 一次的东西,像这样:
`dataframe %$%
t.test(vector1, vector2, paired = T)
cohen.d.(vector1, vector2, paired = T)`
只需列出其中的两件事:
attitude %$% list(t.test(rating, complaints), cohen.d(rating, complaints))
[[1]]
Welch Two Sample t-test
data: rating and complaints
t = -0.5970993, df = 57.53962, p-value = 0.5527835
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-8.560849235 4.627515902
sample estimates:
mean of x mean of y
64.63333333 66.60000000
[[2]]
Cohen's d
d estimate: -0.1541703764 (negligible)
95 percent confidence interval:
inf sup
-0.6717788229 0.3634380702
我想结合这两个功能:
`dataframe %$%
t.test(vector1, vector2, paired = T)
dataframe %$%
cohen.d.(vector1, vector2, paired = T)`
变成只需要 data.frame 一次的东西,像这样:
`dataframe %$%
t.test(vector1, vector2, paired = T)
cohen.d.(vector1, vector2, paired = T)`
只需列出其中的两件事:
attitude %$% list(t.test(rating, complaints), cohen.d(rating, complaints))
[[1]]
Welch Two Sample t-test
data: rating and complaints
t = -0.5970993, df = 57.53962, p-value = 0.5527835
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-8.560849235 4.627515902
sample estimates:
mean of x mean of y
64.63333333 66.60000000
[[2]]
Cohen's d
d estimate: -0.1541703764 (negligible)
95 percent confidence interval:
inf sup
-0.6717788229 0.3634380702