Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个包含多次患者就诊的数据库,例如
1 1 1 1 2 2 3 3 3 3 4 4 4 4
它们在一列中(尽管此处显示为一行),我想知道如何计算我有多少科目。就像在这种情况下:4
我不知道在 R 中使用哪个代码。
谢谢你。
如果我没记错的话,你只是想知道你有多少科目。
在您的情况下,您有 4 个主题:1、2、3 和 4。
然后,您说的列是否存储在 somedata.frame中,例如,您有一个选择:
data.frame
length(unique(data$subjects))
或者,如果它存储在vector:
vector
length(unique(vector.subjects))
我希望这就是你要找的。
unique
length