remap values from one vector to the other

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

remap values from one vector to the other

alaios
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: remap values from one vector to the other

Gerrit Eichner
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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: remap values from one vector to the other

Jim Lemon
In reply to this post by alaios
On 10/31/2013 08:23 PM, 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?
>
Hi Alex,
Try rescale in plotrix.

Jim

______________________________________________
[hidden email] 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.