KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In R, what is the most efficient/idiomatic way to count the number of TRUE values in a logical vector? I can think of two ways: z <- sample(c(TRUE, FALSE), 1000, rep = TRUE) sum(z) # [1] 498 table(z)["TRUE"] # TRUE # 498 Which do you prefer? Is there anything even better?
Tags (comma-separated)
Save Edits
Cancel