【发布时间】:2021-12-09 22:47:18
【问题描述】:
我是 R 编程新手。我不知道我们是否可以对数字对象使用 switch 语句。
这是我的代码,
myfunction <- function() {
x <- 10
switch(x,
1={
print("one")
},
2={
print("two")
},
3={
print("three")
},
{
print("default") #Edited one..
}
)
}
我收到了这个错误,
test.R:4:18: unexpected '='
3: switch(x,
4: 1=
^
请帮我解决这个问题。
【问题讨论】:
标签: r switch-statement