Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Generate sequence of powers of ten

Tags:

r

How do you generate the sequence of numbers 1, 10, 100, 1000, 10000, ... quickly/efficiently in R?

I know seq can give you a sequence of numbers separated by some interval, but is there a function that can give you powers of a number?

like image 507
jmtoung Avatar asked Feb 13 '14 22:02

jmtoung


People also ask

How to generate a power sequence of two in R?

How to generate a power sequence of two in R? In R, for the calculation of power we can simply use power operator ^ and this will be also used in case of generating a power sequence. For example, if we want to generate a power sequence from 1 to 5 of 2 then we can use the code 2^ (1:5) this will result 2 4 8 16 32.

How to calculate the power of a power in R?

In R, for the calculation of power we can simply use power operator ^ and this will be also used in case of generating a power sequence. For example, if we want to generate a power sequence from 1 to 5 of 2 then we can use the code 2^ (1:5) this will result 2 4 8 16 32.

How to generate a sequence of numbers in R using seq ()?

The seq () is a standard general with a default method to generate the sequence of numbers. To generate a sequence of numbers in R, use the seq () method. The seq () is an inbuilt R generic method that generates the regular sequences.

How to generate power sequence from 1 to 5 of 2?

For example, if we want to generate a power sequence from 1 to 5 of 2 then we can use the code 2^ (1:5) this will result 2 4 8 16 32.


1 Answers

10^(0:10)
#  [1] 1e+00 1e+01 1e+02 1e+03 1e+04 1e+05 1e+06 1e+07 1e+08 1e+09 1e+10
like image 121
josliber Avatar answered Oct 27 '22 23:10

josliber