Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
667 views
in Technique[技术] by (71.8m points)

r - Why does function c() accept an undocumented argument?

The documentation for the base function c() shows its default arguments as

c(..., recursive = FALSE)

Now, if we define

lst <- list(x = 1:5, y = 6:10)

and then combine the list with

c(lst, recursive = TRUE)
# x1 x2 x3 x4 x5 y1 y2 y3 y4 y5 
#  1  2  3  4  5  6  7  8  9 10 

the list is collapsed, and the names are kept.

But we can also use another, undocumented argument, use.names, to remove the names.

c(lst, recursive = TRUE, use.names = FALSE)
# [1]  1  2  3  4  5  6  7  8  9 10

Why isn't use.names documented as one of the arguments of c() ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think that it is due to the recursive=TRUE which I believe must use the same code as unlist. The use.names parameter is described in ?unlist.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...