为什么函数c()接受未记录的参数? [英] Why does function c() accept an undocumented argument?

查看:111
本文介绍了为什么函数c()接受未记录的参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本函数 c()的文档将其默认参数显示为

  c(...,递归= FALSE)

现在, p>

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

,然后将列表与

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

该列表已折叠,名称已保存。



但我们也可以使用另一个,无证的参数 use.names ,删除名称。 lst,recursive = TRUE,use.names = FALSE)
#[1] 1 2 3 4 5 6 7 8 9 10

为什么 use.names 记录为的其中一个参数 c()

解决方案

我认为这是由于 recursive = TRUE 我相信它必须使用与 unlist 相同的代码。 use.names 参数描述于?unlist


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() ?

解决方案

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.

这篇关于为什么函数c()接受未记录的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆