Created
January 19, 2019 22:07
-
-
Save mustafaascha/0877ed260530af180793fbc56c5e833a to your computer and use it in GitHub Desktop.
Format PubMed file exports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pubmed_cv <- function(fl_nm) { | |
library(tidyverse) | |
readLines("pubmed_result.txt") %>% | |
(function(z) z[z != ""]) %>% | |
(function(cv) { | |
grep("^[0-9]+?:", trimws(cv)) %>% | |
list( | |
beginnings = ., | |
ends = compose(as.numeric, na.omit)(c(lead(.) - 1, length(cv))) | |
) %>% | |
pmap_chr(~ reduce(cv[.x:.y], paste, .init = "")) | |
}) %>% | |
trimws() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment