library(tidyverse)
library(anytime)
# Data Repo Johns Hopkins CSSE
# https://github.com/CSSEGISandData/COVID-19
url <- "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv"
dta_raw <- read_csv(url, col_types = cols()) %>%
select(-Lat, -Long)
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
// save to windows-user directory | |
linters: with_defaults(object_name_linter = NULL, | |
object_length_linter(50), | |
commented_code_linter = NULL, | |
object_usage_linter = NULL, | |
line_length_linter(120), | |
cyclocomp_linter = cyclocomp_linter(50)) |
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
library(tidyverse) | |
library(rvest) | |
get_uf <- function(y) { | |
# y <- 2016 | |
message(y) | |
seleccionador <- ifelse(y <= 2012, first, last) |
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
# essentially same as before but now restructured into a function: getCitingPMIDs() | |
getCitingPMIDs <- function(PMID) { | |
lines <- readLines(paste0("https://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi?dbfrom=pubmed&linkname=pubmed_pubmed_citedin&id=", PMID)) # construct quering URL using the PMID parameter in resTargetRecord, and fetch its contents into object lines | |
citingPMIDs <- sub("^.*(<Id>)(.*)(</Id>)", "\\2", lines[grep("<Id>", lines)]) # filter out lines in lines that contain <Id> and then filter out the content between <Id> and </Id>.Store in object citingPMIDs | |
citingPMIDs <- citingPMIDs[-1] # remove first entry in citingPMIDs, which is the target record | |
return(citingPMIDs) | |
} |
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
#' Plot network of package dependencies | |
#' | |
#' @param pkg package description, can be path or package name. See \code{\link[devtools]{as.package}} for | |
#' more information. | |
#' | |
#' @details The resulting plot visualizes the network of package dependencies. If you are trying to cut down | |
#' on package dependencies look for big red dots that represent a lot of upstream but few downstream | |
#' dependencies. | |
#' @import ggplot2 | |
#' @export |
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
## This function computes the (normalized) marginal likelihood. | |
## You will not use this function directly. | |
p.y.alt = function(t.stat, N, log.prior.dens,lo=-Inf,up=Inf,...){ | |
normalize = integrate(function(delta,...){ | |
exp(log.prior.dens(delta, ...)) | |
}, lower = lo, upper = up, ...)[[1]] | |
py = integrate(function(delta,t.stat,N,...){ | |
exp( | |
dt(t.stat, N - 1, ncp = delta*sqrt(N), log = TRUE) + |
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
#Article Network ver 2 | |
#============================ | |
# This program will scrape all citing articles surrounding one main article and | |
# create: 1) a list of most cited articles, 2) lists of main authors, 3) network of articles | |
# Mike Barnkob, December 28th 2015. | |
# www.mikebarnkob.dk | |
#Background and references | |
#1. https://cran.r-project.org/web/packages/rentrez/vignettes/rentrez_tutorial.html#advanced-counting |