所以这是我的问题:
为什么会发生这种情况:
x < - c(9,5)
SEQ(x)的
[1] 1 2
为什么我得到1和2,不应该出错?
以下是几个例子:
x < - c(9,5,9)
SEQ(x)的
[1] 1 2 3
x < - c(9,5,9,9)
SEQ(x)的
[1] 1 2 3 4
答案 0 :(得分:0)
让我向您展示seq
可通过?seq
访问的部分帮助:
Typical usages are
seq(from)
The fifth form generates the sequence 1, 2, ..., length(from)
(as if argument along.with had been specified),
unless the argument is numeric of length 1 when it is interpreted as 1:from
(even for seq(0) for compatibility with S).
Using either seq_along or seq_len is much preferred
(unless strict S compatibility is essential).
因此,如果您尝试使用
,则不会收到错误消息x<-c(1,2,3,4,5)
seq(x)
,但如果您尝试使用多个参数
,当然会出现错误x<-c(1,2,3,4,5)
seq(x,3)