Commit c7d3f3f0 authored by Karthik Ram's avatar Karthik Ram
Browse files

temp stuff

parent 394e8b41
language: c
script: "./travis-tool.sh run_tests"
before_script:
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
- chmod 755 ./travis-tool.sh
- "./travis-tool.sh bootstrap"
- "./travis-tool.sh install_deps"
language: r
notifications:
slack:
secure: PcdJMRncDb0dO4bGZLc8tcjhakOdhglyNQr8acdL1Wrq23Qb+ZF6fFfaahrbpSRD+pdpnXUXkmhWjbuqfHY1mnvC9gsFMr9KD9P82hJs2luRUs+mZBKWU45v4puAm19Zepr0P/rsj0KUJmcJepsxLo1ccjOY0xSxzf7jvyf8lx0=
Package: rAltmetric2
Package: rAltmetric
Title: Provides a programmatic interface the the Altmetric.com API on article level metrics.
Version: 0.1.0.9000
Version: 1.0.0.99
Authors@R: 'Karthik Ram <karthik.ram@gmail.com> [aut, cre]'
Description: The package allows for retrieval of metrics on various
Description: Programmatic interface to the Altmetric.com API.
Depends: R (>= 3.1.1)
License: MIT + file LICENSE
LazyData: true
......@@ -10,4 +10,5 @@ Imports:
assertthat,
httr,
jsonlite
Suggests:
dplyr
......@@ -2,5 +2,5 @@
export(citations)
export(metrics)
import(assertthat)
import(httr)
importFrom(assertthat,assert_that)
......@@ -10,7 +10,6 @@
#' @param subject Comma delimited list of slugified journal subjects. Include only articles from journals matching any of the supplied NLM subject ontology term(s).
#' @param foptions A list of additional arguments for \code{httr}. There is no reason to use this argument except for debugging purposes.
#' @import httr
#' @importFrom assertthat assert_that
#' @export
#' @examples
#' citations(day = '1d')
......@@ -28,7 +27,18 @@ citations <- function(day, page = NULL, num_results = 100, cited_in = NULL, doi_
warn_for_status(data)
results <- content(data, as = 'text')
res <- jsonlite::fromJSON(results, flatten = TRUE)
res$results <- as.data.frame(apply(res$results, 2, flat_list))
res$query <- data.frame(t(unlist(res$query)))
class(res) <- "altmetric"
res
}
#' NoRd
#' @param foo input column
flat_list <- function(foo) {
if(identical(class(foo), "list")) {
foo <- vapply(foo, paste, collapse = ", ", character(1L))
}
foo
}
......@@ -3,6 +3,7 @@
#' Returns metrics for any standard identifier such as doi, arxiv, pmid, id, or ads.
#' @param identifier The identifier passed in the format "identifier/id".
#' @export
#' @import assertthat
#' @examples \dontrun{
#' foo <- metrics(identifier = "arxiv/1108.2455")
#' # This is a failed example
......@@ -26,11 +27,18 @@ metrics <- function(identifier) {
results <- content(data, as = 'text')
# Needs more clean up here
res <- jsonlite::fromJSON(results, flatten = TRUE)
res
res <- sapply(res, flatten_nested_list)
do.call(cbind, res)
}
}
#' @param panda input foo
#' @noRd
flatten_nested_list <- function(panda) {
fnames <- names(panda)
z <- data.frame(t(unlist(panda)))
names(z) <- fnames
z
}
# Altmetric2
# Altmetric
This is the reworked version of rAltmetric (temp repo will get merged into rAltmetric shortly)
\ No newline at end of file
This package provides a way to programmatically retrieve altmetric data from [altmetric.com](http://altmetric.com) for any publication with the appropriate identifer.
% Generated by roxygen2 (4.1.0): do not edit by hand
% Please edit documentation in R/citations.R
\name{flat_list}
\alias{flat_list}
\title{NoRd}
\usage{
flat_list(foo)
}
\arguments{
\item{foo}{input column}
}
\description{
NoRd
}
Version: 1.0
RestoreWorkspace: No
SaveWorkspace: No
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
Encoding: UTF-8
AutoAppendNewline: Yes
StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment