[R] remap values from one vector to the other

Gerrit Eichner Gerrit.Eichner at math.uni-giessen.de
Thu Oct 31 10:50:56 CET 2013


Alex,

it is a bit unclear what you mean by "remap" etc., but maybe

y0 <- 880e6;   y1 <- 1020e6
x0 <- 1;       x1 <- ncol(x)

y0 + (x0-1):x1 * (y1 - y0)/(x1 - (x0-1))

gives what you want.

  Hth  --  Gerrit


On Thu, 31 Oct 2013, Alaios wrote:

> Hi everyone,
> I am plotting some legend and I am using the axis(at=..) to specify the place to plot the marks I want.
>
> My plotted data have ncol(x) so the at places have values that span from 1 to ncol(x)
>
> there I would like to be able to map values that go from 880e6 to 1020e6.....
> so
> 880e6 remaps to 1
> ....
>
> 1020e6 repams to ncol(x)
>
> what I do not know how to do is to remap the values that are between 880e6 and 1020e6 between then 1 and ncol(x).
>
> Can someone help me find an appropriate function for that?
>
> I would like to thank you in advance for your help
>
> Regards
> Alex
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list