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.
I read something about str(data) but I can't find it there. Thank you in advance. (I am new in 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. You can use the following code:
length(unique(iris$Species))
Output:
[1] 3
So this means there are 3 unique values in the species column.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.