View source: R/filter_joined.R
count_vals | R Documentation |
Count number of observations where a variable equals a value.
count_vals(var, val)
var |
A vector |
val |
A value |
Utilities for Filtering Observations:
filter_exist()
,
filter_extreme()
,
filter_joined()
,
filter_not_exist()
,
filter_relative()
,
max_cond()
,
min_cond()
library(tibble)
library(dplyr, warn.conflicts = FALSE)
library(admiral)
data <- tribble(
~USUBJID, ~AVISITN, ~AVALC,
"1", 1, "PR",
"1", 2, "CR",
"1", 3, "NE",
"1", 4, "CR",
"1", 5, "NE",
"2", 1, "CR",
"2", 2, "PR",
"2", 3, "CR",
"3", 1, "CR",
"4", 1, "CR",
"4", 2, "NE",
"4", 3, "NE",
"4", 4, "CR",
"4", 5, "PR"
)
# add variable providing the number of NEs for each subject
group_by(data, USUBJID) %>%
mutate(nr_nes = count_vals(var = AVALC, val = "NE"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.