Why doesn't the R () attribute function work when using explicit arguments?

I work with RODBCand parallelto make some queries on the data system for some internal reports. To make it easier to create new connections, I'm going to extract the connection string from the object RODBC. For this, I planned to use attributes(). However, I came across behavior that I do not understand. The following is a minimal working example:

> example.data <- data.frame(letters = sample(x = LETTERS,size = 20,replace = T),
+                            numbers = sample(x = 0:9,size = 20,replace = T))
> 
> attributes(obj = example.data)
Error in attributes(obj = example.data) : 
  supplied argument name 'obj' does not match 'x'
> attributes(example.data)
$names
[1] "letters" "numbers"

$row.names
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20

$class
[1] "data.frame"

It should be noted that the behavior obj =is one tab suggested by RStudio. However, this causes an error. I tried to look at the source code for attributes, but this is a primitive, so I would have to dig into the C source, which I'm not so used to.

attributes() , (obj =), , ? ( RStudio obj =?)

+4
1

. , , x.

attributes(x = example.data)

, attributes() , -, R. (formals(attributes) NULL). R , . , . .

, , .

isS4(pi)
# [1] FALSE
# documented parameter name is "object"
isS4(object=pi)
# Error in isS4(object = pi) : 
#   supplied argument name 'object' does not match 'x'
isS4(x=pi)
# [1] FALSE

, , x: . seq_along ( " .with =" ) quote ( "expr =" ).

+5

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


All Articles