[R] Meaning of following function

Joshua Wiley jwiley.psych at gmail.com
Sun Aug 1 20:35:02 CEST 2010


On Sun, Aug 1, 2010 at 7:56 AM, Ron Michael <ron_michael70 at yahoo.com> wrote:
> Hi friends, I am aware of the function "-"() which acts as minus in ordinary computations. For example:
>
>> "-"(3, 1)
> [1] 2
>
> However what is the meaning of
>> "-"(3)
> [1] -3

This seems quite functionally useful; consider the behavior of some of
the other operators:

>  - 3
[1] -3
> --3
[1] 3
> +3
[1] 3
> /3
Error: unexpected '/' in "/"
> *3
Error: unexpected '*' in "*"

'-' and '+' taking one argument is rather convenient.

>
> I was expecting R to generate some error as it does for "*"(3). What is the logic for that calculation?
>
> Thanks,
>
>
>        [[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.
>
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list