名称和姓氏有什么区别 [英] what is the difference between names and colnames
问题描述
我只想了解在使用<$ c $时名称
和 colnames
之间是否存在区别c> data.frame 。两者的行为似乎相同。我可以用另一个替换吗?
I just want to understand if there is a difference between names
and colnames
when working with data.frame
. Both seems to behave the same way. Can I subsitute one by the other?
推荐答案
data.frames是否相同? 是
Are they the same for data.frames? YES
它们在总体上是否相同?
不完全是-最大的区别是 colnames 也适用于 matrix ,而 names 则不行(仅 dataframes )。
Are they the same in general? Not quite--the big difference is that colnames also works for matrices, whereas names does not (just dataframes).
此外,您可以使用名称设置/获取向量名称(而且,由于明显的原因,您不能使用 colnames 执行此操作-结果为NULL且设置错误)。
In addition, you can use names to set/get the names of vectors (and, for obvious reasons, you can't do this with colnames--the result is NULL for getting and an error for setting).
这篇关于名称和姓氏有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!