-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Sorry in advance for a question without a reproducible example. I thought I would check if you have a quick suggestion as to my mistake. I have one target that is always outdated everytime I start a fresh R session. The target looks like this: ukbb_drug_counts = count_ukbb_drug_users(ukbb_munge_drug_users, drug_codes_interest). The two arguments use upstream targets as inputs: ukbb_munge_drug_users and drug_codes_interest.
The function looks as follows:
count_ukbb_drug_users <- function(ukbb_munge_drug_users, drug_codes_interest){
data <- ukbb_munge_drug_users %>% dplyr::select(paste0(drug_codes_interest$molecule, "_users")) %>% map_df(~length(which(.==1))) %>% t()
return(data)
}
Its purpose is to simply count the number of "users" of each drug from a dataset of drug users (0/1 = no/yes). I've included a snapshot of the data below. Is there something obviously wrong with the function such that it would always be outdated? I've tried using deps_code on it, but I don't notice anything. It only takes <1 second to run and it has no downstream targets so for now it's not a huge deal, but I would like to know what I'm doing wrong. Thanks in advance!
loadd(ukbb_munge_drug_users)
loadd(drug_codes_interest)
head(ukbb_munge_drug_users)
eid amisulpride_users aripiprazole_users clozapine_users
1 4845585 0 0 0
2 2326469 0 0 0
3 3665794 0 0 0
4 3647543 0 0 0
5 1303873 0 0 0
6 4818681 0 0 0
mirtazapine_users olanzapine_users quetiapine_users risperidone_users
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
5 0 0 0 0
6 0 0 0 0
valproate_users
1 0
2 0
3 0
4 0
5 0
6 0
drug_codes_interest$molecule
[1] "amisulpride" "aripiprazole" "clozapine" "mirtazapine" "olanzapine"
[6] "quetiapine" "risperidone" "valproate"
count_ukbb_drug_users(ukbb_munge_drug_users, drug_codes_interest)
[,1]
amisulpride_users 181
aripiprazole_users 78
clozapine_users 57
mirtazapine_users 1432
olanzapine_users 615
quetiapine_users 359
risperidone_users 310
valproate_users 1495