'number of times specific value in each column R
I have:
library(tidyverse)
df <- tibble(one=c(1,1,1,2,2,2,3,3),
log1 = c(TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE),
log2 = c(TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE),
log3 = c(TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE))
I want to find number of times the word "FALSE" appears in each column and group and return a df
I have tried map_df(df, function(x) sum(x==FALSE)) and
df %>%
group_by(one) %>%
map_df( function(x) sum(x==FALSE))
but they do not break into separate groups.
this also errors out
df %>%
group_by(one) %>%
summarise( function(x) sum(x==FALSE))
Any suggestions?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


