This file contains hidden or 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
install.packages("devtools") | |
require(devtools) | |
install_github("rplos", "rOpenSci", "almv3") | |
require(rplos) | |
out <- almplosallviews(doi='10.1371/journal.pmed.0050201', info='detail') | |
almplotallviews(out, type="totalmetrics") | |
almplotallviews(out, type="history") |
This file contains hidden or 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
#' Search the Phylotastic Taxonomic Name Resolution Service | |
#' | |
#' Match taxonomic names using the Taxonomic Name Resolution Service (TNRS). | |
#' Returns score of the matched name, and whether it was accepted or not. | |
#' | |
#' @import RCurl XML plyr stringr RJSONIO | |
#' @param query Quoted taxonomic names to search in a vector (character). | |
#' @param output 'all' for raw list output or 'names' for matched names | |
#' and their match scores, plus plant family names (character). | |
#' @param sleep Numer of seconds by which to pause by before retrieving the |
This file contains hidden or 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 gist is an example of getting altmetrics data on PLoS papers. | |
## In a nutshell, this script reads in a list of DOIs provided by Martin Fenner of PLoS, and gets the historical altmetrics | |
## data on each DOI, and writes it to a txt file. You can do lots of things with this data. How do different altmetrics | |
## relate to one another within a paper, across papers, how do they vary through time for a paper, etc. | |
## I ran this in an EC2 using an m2.2xlarge instance. | |
## It took about XX to run. | |
## The resulting file was about XXX mb. | |
library(devtools) | |
install_github('rplos', 'ropensci', 'almv3') |
This file contains hidden or 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
require(ggplot2); require(reshape2); require(grid); library(gsl); library(wrightscape) | |
theme_set(theme_bw()) | |
plot.path_sim <- function(x, ...) ggplot(x) + geom_line(aes(time, | |
value, group = rep), alpha = 0.05) | |
reps <- 500 | |
X <- bm_path_sim(reps = reps) | |
Y <- ou_path_sim(reps = reps, alpha = 6) | |
W <- brownie_path_sim(reps = reps, sigma = 0.3, sigma2 = 1.2, release_frac = 0.7) # has 1/release_frac time = 2 | |
px <- plot.path_sim(X) + opts(title = "Brownian Motion") + | |
coord_cartesian(ylim = c(-2, 2)) + ylab("trait value") |
This file contains hidden or 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
install.packages("packdep") | |
library(packdep) | |
d <- map.depends() | |
dat <- dependencies(d) | |
row.names(dat) <- NULL | |
dat[dat$package %in% c("rgbif","rfigshare","rplos","ropensnp","ritis","rentrez","rebird","treebase","RMendeley","rfishbase"), ] | |
## Output on 07-Nov-12 | |
> dat[dat$package %in% c("rgbif","rfigshare","rplos","ropensnp","ritis","rentrez","rebird","treebase","RMendeley","rfishbase"), ] |
This file contains hidden or 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
myvector <- c(1,2,3) # create a vector (numbers in this case) | |
myvector # look at it, it doesn't have names, but we can add them | |
names(myvector) # there are no names on the elements of the vector | |
names(myvector) <- c("a","b","c") # doing "names(object) <- X" names the elements of the vector | |
myvector # now each element has a name in the vector | |
myvector[["a"]] # we can call each element by its name if want to now, or by doing | |
myvector["a"] |
This file contains hidden or 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
> temp <- getURL("http://pub.orcid.org/0000-0002-9341-7985/orcid-works") | |
> xmlParse(temp) | |
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<orcid-message xmlns="http://www.orcid.org/ns/orcid"> | |
<message-version>1.0.7</message-version> | |
<orcid-profile type="user"> | |
<orcid>0000-0002-9341-7985</orcid> | |
<orcid-history> | |
<creation-method>website</creation-method> | |
<completion-date>2012-10-16T13:08:32.715+01:00</completion-date> |
This file contains hidden or 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
is.invasive() | |
##Description## | |
#This function check which species (both plants and animals) are considered "invaders" somewhere in the | |
# world. For that end, it checks GISD (http://www.issg.org/database/welcome/) and returns a value, either | |
#"Not invasive" or the brief description presented in GISD. Note that the webpage contains more | |
#information. Also note that the function won't tell you if it's exotic in your area, a lot of exotic | |
#species are not considered invaders (yet). As expected, the function is as good as the database is, which | |
#I find quite reliable and well maintained. The database is also able to recognize a lot (but not all) of |
This file contains hidden or 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(plyr) | |
m1 <- lm(Petal.Length ~ Petal.Width, data=iris) | |
m2 <- lm(Petal.Length ~ Petal.Width + Species, data=iris) | |
tt <- function(x) { | |
temp <- data.frame(rnorm(1), summary(x)[4], summary(x)[8]) | |
names(temp) <- c("model", "est", "se", "t", "p", "r2") | |
temp | |
} |
This file contains hidden or 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
install.packages("wordcloud") | |
library(wordcloud) | |
wordcloud( | |
"Many years ago the great British explorer George Mallory, who | |
was to die on Mount Everest, was asked why did he want to climb | |
it. He said, \"Because it is there.\" | |
Well, space is there, and we’re going to climb it, and the | |
moon and the planets are there, and new hopes for knowledge | |
and peace are there. And, therefore, as we set sail we ask |