Was wondering if anyone would be able to help me in turning an ifelse() statement into case_when(), accompanied with mutate to create a new variable.
I haven't attached a reprex as I'm unsure if it would be needed, but will add one if so.
Thanks for any help.
ifelse(adherence.test$date %in% exac.filter$exac.start &
adherence.test$patientid %in% exac.filter$patientid,
as.character(adherence.test$date), NA)
#Attempt
adherence.test <- Adherence.merge %>%
mutate(exac.date = ifelse(adherence.test$date %in%
exac.filter$exac.start & adherence.test$patientid %in%
exac.filter$patientid, as.character(adherence.test$date),
TRUE ~ NA))
Error: Column `exac.date` must be length 1 (the group size), not 320
Hi!
To help us help you, could you please prepare a repr oducible ex ample (reprex) illustrating your issue? Having a sample of your data will be very helpful in diagnosing the issue you are having. Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
1 Like
system
Closed
May 20, 2020, 7:06pm
3
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.