Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add transformation step to pubmed searches #17

Open
meerapatelmd opened this issue Dec 8, 2020 · 0 comments
Open

add transformation step to pubmed searches #17

meerapatelmd opened this issue Dec 8, 2020 · 0 comments

Comments

@meerapatelmd
Copy link
Owner

library(fantasia)
library(tidyverse)

output <-
qOMOP(
"
        SELECT DISTINCT search_term, search_type, citation_date
        FROM patelm9.pm_results
        "
) %>%
        rubix::split_deselect(col = search_term) %>%
        purrr::map(function(x) x %>%
                                group_by(search_type) %>%
                                summarize(average_date = mean(citation_date, na.rm = TRUE),
                                          sd_days = sd(citation_date, na.rm = TRUE),
                                          record_count = length(centipede::no_na(citation_date)))
        ) %>%
        purrr::map(function(x) x %>%
                                tidyr::pivot_wider(names_from = search_type,
                                                   names_glue = "{search_type}_{.value}",
                                                   values_from = !search_type)
                ) %>%
        purrr::map(function(x) x %>%
                           dplyr::select(dplyr::starts_with("earliest"),
                                         dplyr::everything())
        )


output2 <-
        output %>%
        dplyr::bind_rows(.id = "search_term")

output2 %>%
        dplyr::filter_at(dplyr::vars(dplyr::contains("sd_days"),
                                     dplyr::contains("average_date")),
                         dplyr::all_vars(!is.na(.)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant