如何使用 R 为前 10 个数字编写一个具有特定间隔的函数,然后为第二个 10 个数字编写一个新间隔,依此类推
How to write a function with an specific interval for the first 10 numbers then a new interval for the second 10 and so on using R
我想得到所有这样增加的数字 10^(seq(1,9,by=1))
然后接下来的 10 10^(seq(10,90,by=10))
... 10^(seq(a,b,by=a))
如果我没理解错的话,这就是你要找的:
get_pwr <- function(a) {
b <- 10^a - a
10^(seq(a, b, by=a))
}
lapply(seq(1,9,by=1), get_pwr)
记住尺寸的限制:R in a 64 bit world
和the-min-max-possible-numeric
也许你可以试试下面的代码
c(sapply(10**(0:log10(a)),function(x) 10**seq(x,9*x,by = x)))
我想得到所有这样增加的数字 10^(seq(1,9,by=1))
然后接下来的 10 10^(seq(10,90,by=10))
... 10^(seq(a,b,by=a))
如果我没理解错的话,这就是你要找的:
get_pwr <- function(a) {
b <- 10^a - a
10^(seq(a, b, by=a))
}
lapply(seq(1,9,by=1), get_pwr)
记住尺寸的限制:R in a 64 bit world
和the-min-max-possible-numeric
也许你可以试试下面的代码
c(sapply(10**(0:log10(a)),function(x) 10**seq(x,9*x,by = x)))