更改订单价值
Change order value
我有这样的数据库:
a <-c(4, 2, 10, 2, 10, 6, 2)
b <-c(4, 6, 70, 8, 18, 4, 3)
rbind(a,b)
我可以创建这样的东西:
x <- (4, 4, 2, 6, 10, 70, 2, 8, 10, 18, 6, 4, 3)
一个DB中包含a和b顺序的这种方式,有可能吗?我需要做一个时间序列,值必须在同一个位置
rbind
仅在两个 vector
的长度相同时才有效,否则会产生意外的输出。即
> rbind(c(4, 3, 5), c(3, 4))
[,1] [,2] [,3]
[1,] 4 3 5
[2,] 3 4 3
Warning message:
In rbind(c(4, 3, 5), c(3, 4)) :
number of columns of result is not a multiple of vector length (arg 2)
当我们c
做一个向量时,它returns从recycling
额外3
一种更通用的方法是 order
基于两个 vector
中值的 sequence
而 c
连接 vector
s`
c(a, b)[order(c(seq_along(a), seq_along(b)))]
[1] 4 4 2 6 10 70 2 8 10 18 6 4 2 3
我有这样的数据库:
a <-c(4, 2, 10, 2, 10, 6, 2)
b <-c(4, 6, 70, 8, 18, 4, 3)
rbind(a,b)
我可以创建这样的东西:
x <- (4, 4, 2, 6, 10, 70, 2, 8, 10, 18, 6, 4, 3)
一个DB中包含a和b顺序的这种方式,有可能吗?我需要做一个时间序列,值必须在同一个位置
rbind
仅在两个 vector
的长度相同时才有效,否则会产生意外的输出。即
> rbind(c(4, 3, 5), c(3, 4))
[,1] [,2] [,3]
[1,] 4 3 5
[2,] 3 4 3
Warning message:
In rbind(c(4, 3, 5), c(3, 4)) :
number of columns of result is not a multiple of vector length (arg 2)
当我们c
做一个向量时,它returns从recycling
3
一种更通用的方法是 order
基于两个 vector
中值的 sequence
而 c
连接 vector
s`
c(a, b)[order(c(seq_along(a), seq_along(b)))]
[1] 4 4 2 6 10 70 2 8 10 18 6 4 2 3