Case_为什么在这里有两个不同的输出?
时,我无法理解为什么输出有所不同
当我使用两种不同的case_时:选项1:
x = 5
y = print("goodmorning")
z = print("goodafternoon")
q = print("goodevening")
case_when(x > 3 ~ y, x < 8 ~ z)
输出1:
[1] "goodmorning"
选项2:
x = 5
case_when(x > 3 ~ print("goodmoring"), x < 8 ~ print("goodafternoon"))
输出2:
[1] "goodmoring"
[1] "goodafternoon"
[1] "goodmoring"
有人可以启发我如何导致两个完全不同的输出 。我相信case_时,当第一次满足A条件时,它会从Case_case跳出,并且这似乎是第一个代码的,但是为什么它不适合第二个代码呢?
I am failing to understand why the output is different when I use two different cases of case_when:
Option 1:
x = 5
y = print("goodmorning")
z = print("goodafternoon")
q = print("goodevening")
case_when(x > 3 ~ y, x < 8 ~ z)
Output 1:
[1] "goodmorning"
Option 2:
x = 5
case_when(x > 3 ~ print("goodmoring"), x < 8 ~ print("goodafternoon"))
Output 2:
[1] "goodmoring"
[1] "goodafternoon"
[1] "goodmoring"
Can someone enlighten me how this results in two completely different outputs. I believed that case_when sequentially and that it jumps out of the case_case when the first time the a condition is met and this seems to hold for the first piece of code, but why does it not hold for the second code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
引用帮助页面(强调我的),
Citing the help page (emphasis mine),