简体   繁体   English

一列中不同观察值的数量

[英]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.您可以使用lengthunique来确定例如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.

相关问题 根据面板长格式中的观察数将列单元格划分为不同的数字 - Dividing a column cell with a different number based on number of observations in a panel long format 如何将观察值转换为列并表示这些观察值的出现次数 - How to transform observations to column and reprensent the number of occurence of these observations 如何计算具有多个观察/行的参与者数量,这些观察/行具有列的不同行中的值组合? - How to count the number of participants with multiple observations/rows that have a combination of values in different rows of a column? 按 R 中的因子水平对不同数量的观察值进行采样 - Sample different number of observations by level of a factor in R 连接具有不同观察数量的两个数据集 - Joining two datasets with different number of observations R中的ifelse语句在表中具有不同数量的观察值 - ifelse statement in R with different number of observations in tables 基于每列中的观察数的子集数据帧 - Subset dataframe based on number of observations in each column 计算每列和按组的观察次数 - Counting number of observations per column and by group 在列的数据框中查找相同的观察值但在另一列中不同 - Find identical observations in a column´s data frame but different in another column 在每次迭代中模拟不同数量的观测值,而无需在R中使用for循环 - Simulating different number of observations at each iteration without using for loop in R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM