I'm working through r-exercises. One requires generating the following vector:
[0.05, 0.5, 5.0, 0.5, 0.05]
The catch is cbind or loops cannot be used.
Here is what I tried:
rep(0.05 * 10^(seq(0,2)), times=2)
But of course that just returns:
[1] 0.05 0.50 5.00 0.05 0.50 5.00
Any ideas?
CodePudding user response:
You can apply abs
to a sequence centered at 0 to symmetrize it:
5*10^-abs(-2:2)
## [1] 0.05 0.50 5.00 0.50 0.05