如何使数列升为幂数

oax*_*att 2 r sequence seq

我有:

cost = c(2^(-5),2^(-3),2^(-1),2^(1),2^(3),2^(5),2^(7),2^(9),2^(11),2^(13),2^(15))
Run Code Online (Sandbox Code Playgroud)

我想要一个更优雅的命令,例如:

seq(from = 2^(-5), to = 2^(15), by = __)
Run Code Online (Sandbox Code Playgroud)

Gre*_*gor 5

^在两个参数中都被向量化,因此您可以提高2幂的线性顺序:

2^seq(from = -5, to = 15, by = 2)
Run Code Online (Sandbox Code Playgroud)