1

I have an asymetrical distribution :

x <- c(rnorm(100, 0, 1),
     rnorm(100, 2.5, 0.5))

enter image description here

I would like to shift it so the old "0" value is now 100 and the old "2" value is now "15". However, I would like to do it without using old nor new min/max values.

Using the scale function is not appropriated as it shifts the mean to an new value, and I'd like to shift a specific value to a new one. I can't make rescale do it neither.

  plot(density(scale(x)*15+100))
  plot(density(scales::rescale(x, from=c(0, 2), to=c(100, 15))))

enter image description here enter image description here

Dominique Makowski
  • 1,511
  • 1
  • 13
  • 30

1 Answers1

0

It works with rescale:

scales::rescale(x, from=c(0, 2), to=c(100, 100+15))

Dominique Makowski
  • 1,511
  • 1
  • 13
  • 30