0

I want to get all the numbers with an increase like this 10^(seq(1,9,by=1)) then the next 10 10^(seq(10,90,by=10)) ... 10^(seq(a,b,by=a))

  • After `10^(seq(10,90,by=10))` would it be `10^(seq(100,900,by=100))` ? Most of the numbers in that vector become infinity. – Ronak Shah Aug 11 '20 at 07:12

2 Answers2

1

Maybe you can try the code like below

c(sapply(10**(0:log10(a)),function(x) 10**seq(x,9*x,by = x)))
ThomasIsCoding
  • 96,636
  • 9
  • 24
  • 81
0

If I understood correctly, thus is what you are looking for:

get_pwr <- function(a) {
  b <- 10^a - a
  10^(seq(a, b, by=a))
}

lapply(seq(1,9,by=1), get_pwr)

bur remember the limitation of the sizes: R in a 64 bit world

and the-min-max-possible-numeric

  • I think you mean `b <- 10^a - a`? (Otherwise, the end of one list is duplicated by the start of the next.) And maybe wrap the `lapply` in `unlist`? – Limey Aug 11 '20 at 07:36