library("knitr") hook_output <- knitr::knit_hooks$get("output") knitr::knit_hooks$set(output = function(x, options) { lines <- options$output.lines if (is.null(lines)) { return(hook_output(x, options)) # pass to default hook } x <- unlist(strsplit(x, "\n")) more <- "..." if (length(lines)==1) { # first n lines if (length(x) > lines) { # truncate the output, but add .... x <- c(head(x, lines), more) } } else { x <- c(if (abs(lines[1])>1) more else NULL, x[lines], if (length(x)>lines[abs(length(lines))]) more else NULL ) } # paste these lines together x <- paste(c(x, ""), collapse = "\n") hook_output(x, options) }) knitr::opts_chunk$set( warning = FALSE, message = FALSE, collapse = TRUE, comment = "#>" )
Client for the Citoid service https://www.mediawiki.org/wiki/Citoid
docs: https://en.wikipedia.org/api/rest_v1/#!/Citation/getCitation
There are two functions, both of which do the same things, except:
cit_oid()
: parses textcit_oid_()
: does not parse text, you can parse later yourselfEven with cit_oid()
though, you get a list of lists, and you may
want to parse it to a data.frame. See an example below.
Stable version
install.packages("rcitoid")
Development version
remotes::install_github("ropensci/rcitoid")
Load the package
library("rcitoid")
use underscore method to get text
cit_oid_("10.1108/jd-12-2013-0166")
DOI
cit_oid("10.1108/jd-12-2013-0166")
PMID
cit_oid(30446726)
PMCID
cit_oid("PMC4679344")
ISBN
cit_oid(1439895619)
because the resulting data is nested and can have missing data slots, it's probably easier to get raw text and manipulate from there.
library(dplyr) pmid <- c(30446726, 30722046, 30687373, 30688010) pmcid <- c("PMC4679344", "PMC6347797", "PMC6347793") isbn <- 1439895619 dois <- c("10.1109/jsac.2011.110806", "10.1007/s00422-006-0078-4", "10.5040/9781474219624-0044", "10.1109/icemi.2009.5274826", "10.1109/wispnet.2017.8299996") res <- cit_oid_(id = c(pmid, pmcid, isbn, dois)) tbl_df(bind_rows(lapply(res, jsonlite::fromJSON)))
rcitoid
in R doing citation(package = 'rcitoid')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.