No, this is not strange. You invoke the data.frame constructor with named and unnamed objects.
I initially assumed that data.frame is a list and uses help (list) to explain the behavior of data.frame. Even the philosophy is the same (named and unnamed argument), it was a mistake, and the answer is to help data.frame
from? data.frame I take this part where we talk about argument names
If the arguments are all named and simple objects (not lists, data matrices), then the argument names will give the column names. For an unnamed simple argument, the dewaxed version of the argument is used as the name (with closed I (...) deleted).
So,
x<-data.frame(name<-c("n1","n2"),age<-c(5,6))
this is equivalent to:
x <- data.frame(c("n1","n2"),c(5,6)) ## unnamed objects The functions return dotted pair list name<-c("n1","n2") age<-c(5,6)
Then for y
y<-data.frame(name=c("n1","n2"),age=c(5,6)) ## named objects functions return a list
But note that this only explains the procedure for naming a simple argument to an object. Naming is more complicated than adding some points. For example, I find it very surprising that theses 2 statements are equivalent (using check.names = T or F):
a <- data.frame(y <- list(x=1)) a <- data.frame(y = list(x=1))
source share