R: 'from' 的长度必须为 1
R: 'from' must be of length 1
我正在使用 R 编程语言。
我正在尝试使用“expand.grid”命令定义网格,其中网格“自我引用”自身:
random_1 <- seq(80,100,5)
random_2 <- seq(random_1,120,5)
random_3 <- seq(85,120,5)
random_4 <- seq(random_3,120,5)
split_1 = seq(0,1,0.5)
split_2 = seq(0,1,0.5)
split_3 = seq(0,1,0.5)
DF_2 <- expand.grid(random_1 , random_2, random_3, random_4, split_1, split_2, split_3)
但是这个returns出现以下错误:
Error in seq.default(random_3, 120, 5) : 'from' must be of length 1
>
有谁知道如何解决这个错误?
谢谢
seq
取单个元素为from
、to
。根据?seq
from, to - the starting and (maximal) end values of the sequence. Of length 1 unless just from is supplied as an unnamed argume
我们可以遍历 'random_1'
lapply(random_1, function(x) seq(x, 120, 5))
对random_3
做同样的事情并构建为
> random_2 <- lapply(random_1, function(x) seq(x, 120, 5))
> random_3 <- seq(85,120,5)
> random_4 <- lapply(random_3, function(x) seq(x, 120, 5))
> split_1 = seq(0,1,0.5)
> split_2 = seq(0,1,0.5)
> split_3 = seq(0,1,0.5)
> DF_2 <- expand.grid(c(list(random_1), random_2, random_3, random_4, list(split_1, split_2, split_3)))
我正在使用 R 编程语言。
我正在尝试使用“expand.grid”命令定义网格,其中网格“自我引用”自身:
random_1 <- seq(80,100,5)
random_2 <- seq(random_1,120,5)
random_3 <- seq(85,120,5)
random_4 <- seq(random_3,120,5)
split_1 = seq(0,1,0.5)
split_2 = seq(0,1,0.5)
split_3 = seq(0,1,0.5)
DF_2 <- expand.grid(random_1 , random_2, random_3, random_4, split_1, split_2, split_3)
但是这个returns出现以下错误:
Error in seq.default(random_3, 120, 5) : 'from' must be of length 1
>
有谁知道如何解决这个错误?
谢谢
seq
取单个元素为from
、to
。根据?seq
from, to - the starting and (maximal) end values of the sequence. Of length 1 unless just from is supplied as an unnamed argume
我们可以遍历 'random_1'
lapply(random_1, function(x) seq(x, 120, 5))
对random_3
做同样的事情并构建为
> random_2 <- lapply(random_1, function(x) seq(x, 120, 5))
> random_3 <- seq(85,120,5)
> random_4 <- lapply(random_3, function(x) seq(x, 120, 5))
> split_1 = seq(0,1,0.5)
> split_2 = seq(0,1,0.5)
> split_3 = seq(0,1,0.5)
> DF_2 <- expand.grid(c(list(random_1), random_2, random_3, random_4, list(split_1, split_2, split_3)))