Purpose in the definition of data.frame

This is not a problem, but something that I accidentally met. However, this is really intriguing for me.

I ran the following line in the console

sc_matrix <- data.frame(sc_start<-rpois(n=15, 0.4), sc_end<-rpois(n=15, 0.3))

and I was very surprised that the exit was

head(sc_matrix, n=5)
#   sc_start....rpois.n...15..0.4. sc_end....rpois.n...15..0.3.
#1                               0                            1
#2                               0                            2
#3                               0                            0
#4                               1                            1
#5                               0                            0

Firstly, I was surprised because the interpreter understood me (even without warning). data.framewas created, although I used the assignment <-inside the constructor data.frame.

Secondly, it is created colnamesin accordance with a rule that changes all non-alpha-numeric to .(period) and used as a name.

After reading the discussion of assignment mappings , I think my question is:

R ? =, , . sc_start<-rpois(n=15, 0.4), .

, <- , , data.frame - NULL. .

+4
2
sc_matrix <- data.frame(sc_start<-rpois(n=15, 0.4), sc_end<-rpois(n=15, 0.3))

, , , , R ( ) <-, . , `<-`(a, 1). , RHS (. help("<-")), .. .

data.frame ( LHS =), substitute . , check.names = TRUE, . , , , - data.frame(1).

+4

,

sc_start <- rpois(n=15, 0.4) 

rpois(n=15, 0.4) sc_start. sc_end <- rpois(n=15, 0.3).

, .

, , ,

data.frame(rpois(n=15, 0.4), rpois(n=15, 0.3))

, R , fix.empty.names FALSE. , . sc_start sc_end.

data.frame(x = sc_start <- rpois(n=15, 0.4), y = sc_end <- rpois(n=15, 0.3))

, x y - = sc_start sc_end - <-.

+2

Source: https://habr.com/ru/post/1692259/


All Articles