Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
rcharts removed from pkg, fix #42
Browse files Browse the repository at this point in the history
  • Loading branch information
sckott committed Jan 6, 2015
1 parent 41430ac commit 332be5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 73 deletions.
4 changes: 0 additions & 4 deletions DESCRIPTION
Expand Up @@ -5,9 +5,6 @@ Description: An R interface to the open source article level metrics API
using the open source app created by PLOS, so you can drop in a different
base URL to the functions in this package to get to not only PLOS data, but
data for Crossref, and more as the open source PLOS software is used.
rCharts is in Enhances; and can be used for creating interactive charts
(e.g., in the function plot_signposts in this package); obtain rCharts at
https://github.com/ramnathv/rCharts.
Version: 0.3.1.99
Date: 2014-11-10
License: MIT + file LICENSE
Expand Down Expand Up @@ -39,4 +36,3 @@ Suggests:
roxygen2,
rplos,
knitr
Enhances: rCharts
46 changes: 7 additions & 39 deletions R/plot_signposts.R
Expand Up @@ -7,20 +7,10 @@
#' @export
#'
#' @param input A data.frame from a search from the \code{\link{alm_signposts}} function
#' @param type Type of chart, one of bar (default), multiBarChart, or
#' multiBarHorizontalChart. multiBarChart or multiBarHorizontalChart
#' options use the library rCharts, specifically the NVD3 javascript library.
#' Choosing multiBarChart or multiBarHorizontalChart opens a visualization in
#' your default browser, while option bar makes a ggplot2 plot within your R session.
#' @param width Only applies with type="interactive", otherwise ignored. Width of
#' the plotting area.
#' @param height Only applies with type="interactive", otherwise ignored. Height of
#' the plotting area.
#' @details Note that DOIs are the unit of replication of each study. When plotting,
#' if the prefix is common among all DOIs, then just the end of the DOI, the numeric
#' part is printed to make plots less ugly.
#' @seealso \code{\link{alm_ids}}, \code{\link{plot_signposts}}
#' @return A data.frame of the signpost numbers for the searched object.
#' @seealso \code{\link{alm_signposts}}
#' @references See a tutorial/vignette for alm at
#' \url{http://ropensci.org/tutorials/alm_tutorial.html}
#' @examples \dontrun{
Expand All @@ -33,32 +23,20 @@
#' '10.1371/journal.pone.0029797','10.1371/journal.pone.0039395')
#' dat <- alm_signposts(doi=dois)
#' plot_signposts(input=dat)
#'
#' # Or you can make an interactive chart
#' plot_signposts(input=dat, type="multiBarChart")
#'
#' # Many DOIs
#' library('rplos'); library('rCharts')
#' dois <- searchplos(q='evolution', fl='id',
#' fq=list('-article_type:correction','doc_type:full'), limit = 10)
#' dat <- alm_signposts(doi=dois$id)
#' ## multiBarChart
#' plot_signposts(input=dat, type="multiBarChart")
#' ## multiBarHorizontalChart
#' plot_signposts(input=dat, type="multiBarHorizontalChart")
#' }

plot_signposts <- function(input, type="bar", width=800, height=500)
{
plot_signposts <- function(input, width=800, height=500){
stripdois <- function(x){
temp <- strsplit(as.character(x$doi), "\\.")
if(all(sapply(temp, function(x) paste0(x[1:3],collapse="")) %in% sapply(temp, function(x) paste0(x[1:3],collapse=""))[[1]])){
doi_parts <- sapply(strsplit(as.character(x$doi), "\\."), "[[", 4)
x <- x[,-1]
x$doi <- doi_parts
x
} else
{ x }
} else {
x
}
}

if(!is.data.frame(input))
Expand All @@ -70,23 +48,13 @@ plot_signposts <- function(input, type="bar", width=800, height=500)
theme_grey(base_size=16) +
geom_bar(stat="identity") +
labs(x="",y="")
} else
if(type=="bar"){
} else {
input <- stripdois(input)
df <- melt(input)
ggplot(df, aes(doi, value)) +
theme_grey(base_size=16) +
geom_bar(stat="identity") +
facet_wrap(~variable, scales="free") +
labs(x="",y="")
} else
{
input <- stripdois(input)
df <- melt(input)
n <- nPlot(value ~ doi, group = "variable", data = df, type = type)
n$set(width = width, height = height)
if(type=="multiBarChart")
n$chart(reduceXTicks = FALSE)
n
}
}
32 changes: 2 additions & 30 deletions man/plot_signposts.Rd
Expand Up @@ -4,25 +4,10 @@
\alias{plot_signposts}
\title{Plot PLOS article-level metrics data.}
\usage{
plot_signposts(input, type = "bar", width = 800, height = 500)
plot_signposts(input, width = 800, height = 500)
}
\arguments{
\item{input}{A data.frame from a search from the \code{\link{alm_signposts}} function}

\item{type}{Type of chart, one of bar (default), multiBarChart, or
multiBarHorizontalChart. multiBarChart or multiBarHorizontalChart
options use the library rCharts, specifically the NVD3 javascript library.
Choosing multiBarChart or multiBarHorizontalChart opens a visualization in
your default browser, while option bar makes a ggplot2 plot within your R session.}

\item{width}{Only applies with type="interactive", otherwise ignored. Width of
the plotting area.}

\item{height}{Only applies with type="interactive", otherwise ignored. Height of
the plotting area.}
}
\value{
A data.frame of the signpost numbers for the searched object.
}
\description{
This can be used in conjuction with the function \code{\link{alm_signposts}}.
Expand All @@ -43,26 +28,13 @@ dois <- c('10.1371/journal.pone.0001543','10.1371/journal.pone.0040117',
'10.1371/journal.pone.0029797','10.1371/journal.pone.0039395')
dat <- alm_signposts(doi=dois)
plot_signposts(input=dat)

# Or you can make an interactive chart
plot_signposts(input=dat, type="multiBarChart")

# Many DOIs
library('rplos'); library('rCharts')
dois <- searchplos(q='evolution', fl='id',
fq=list('-article_type:correction','doc_type:full'), limit = 10)
dat <- alm_signposts(doi=dois$id)
## multiBarChart
plot_signposts(input=dat, type="multiBarChart")
## multiBarHorizontalChart
plot_signposts(input=dat, type="multiBarHorizontalChart")
}
}
\references{
See a tutorial/vignette for alm at
\url{http://ropensci.org/tutorials/alm_tutorial.html}
}
\seealso{
\code{\link{alm_ids}}, \code{\link{plot_signposts}}
\code{\link{alm_signposts}}
}

0 comments on commit 332be5a

Please sign in to comment.