[英]number of different observations in a column
How can I find how many different observations there are in a column?我怎样才能找到一列中有多少个不同的观察结果? For example in a column "species" with 3000 rows I want to find how many different species there are.
例如,在具有 3000 行的“物种”列中,我想找出有多少种不同的物种。
I read something about str(data) but I can't find it there.我读了一些关于 str(data) 的东西,但在那里找不到。 Thank you in advance.
先感谢您。 (I am new in R)
(我是 R 的新手)
You can use length
and unique
to determine for example in the iris
dataset how many unique species there are in the Species
column.您可以使用
length
和unique
来确定例如iris
数据集中的Species
列中有多少独特物种。 You can use the following code:您可以使用以下代码:
length(unique(iris$Species))
Output: Output:
[1] 3
So this means there are 3 unique values in the species column.所以这意味着物种列中有 3 个唯一值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.