[R] Invert the sign of a number
murdoch at stats.uwo.ca
Thu Oct 29 14:05:22 CET 2009
On 29/10/2009 6:06 AM, Fran100681 wrote:
> just a simple question
> How can I do to invert the sign of a number? (for example: -4 to 4, 2 to -2
> and so on..)
> I was looking for a specific function in R but I didn't found it...
> thank you
You want the unary - operator. For example,
has opposite signs to x.
will work to give 4, but it will scare C programmers, so it's probably
best to use parentheses:
More information about the R-help