Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does '->'(12, b) give an error?

Tags:

r

In R operators can also be expressed as a function call, e.g.

'<-'(b, 12)

for b <- 12.
Why does the following give an error:

'->'(12, b)

? (The code 12 -> b works as expected.)

like image 627
jogo Avatar asked Aug 07 '18 08:08

jogo


People also ask

What is the 52 rule?

Findings by the court. (a) Findings. – (1) In all actions tried upon the facts without a jury or with an advisory jury, the court shall find the facts specially and state separately its conclusions of law thereon and direct the entry of the appropriate judgment.

What are the 3 most common post trial motions?

The most common post-trial motions include:Motion to dismiss. Motion for judgment of acquittal. Motion for a trial order of dismissal.

What is the meaning of Rule 9?

In all averments of fraud or mistake, the circumstances constituting fraud or mistake shall be stated with particularity. Malice, intent, knowledge, and other condition of mind of a person may be averred generally.


1 Answers

Because operators are "translated" to functions by the parser and both left and right assignment are parsed to the <- function. There is no right assignment function.

e <- quote(b <- 12)
as.list(e)
#[[1]]
#`<-`
#
#[[2]]
#b
#
#[[3]]
#[1] 12

e <- quote(12 -> b)
as.list(e)
#[[1]]
#`<-`
#
#[[2]]
#b
#
#[[3]]
#[1] 12
like image 96
Roland Avatar answered Oct 22 '22 09:10

Roland