Skip to content

add transformation step to pubmed searches #17

@meerapatelmd

Description

@meerapatelmd
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(.)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions