Skip to content

Instantly share code, notes, and snippets.

library(rAltmetric)
library(purrr)
# we launch purrr because it gives us the safely function
ids <- c("10.1371/journal.pbio.0000002",
"10.1371/journal.pbio.0000003",
"10.1371/journal.pbio.0000004",
"10.1371/journal.pbio.0000005",
"10.1371/journal.pbio.0000006",

What is this?

A scratchpad for a classifer of software libraries focussing on a number of areas that will guide users to make more informed decisions about whether to include a library within their own project.

See librariesio/libraries.io#1486 for more information.

Themes/Questions

There are a number of key themes here that we need to look at. Within each I have posed a number of questions that might be of interest to a developer or maintainer.

Code

  • What scale is this project? - Looking at things like novel LoC, #dependencies and LoC in dependencies perhaps.
library(tidyverse)
library(leaflet)
# If you don't have leaflet, install with:
# install.packages("leaflet")
# How to map data with Leaflet
download.file(
"https://commondatastorage.googleapis.com/ckannet-storage/2012-07-09T214020/global_airports.csv",
destfile = "global_airports.csv"
library(magick)
# Package and issues available at: https://github.com/ropensci/magick
# -------------------------------------------------------------------------
wizard_hat <- image_read("http://i.imgur.com/rpJ09lY.png") %>%
image_scale("x100")
bigdata <-
image_read('https://i.imgur.com/6X65Els.jpg') %>%
image_scale("x300")

Explore functions in a package

lsp <- function (package, pattern, all.names = FALSE)
{
  package <- deparse(substitute(package))
  ls(pos = paste("package", package, sep = ":"), all.names = all.names,
     pattern = pattern)
}
@karthik
karthik / separate_steps.R
Created September 29, 2016 09:58 — forked from dgrtwo/separate_steps.R
separate_steps.R
#' Convert a dplyr expression to a list of step objects
separate_steps <- function(expr, iscall=FALSE) {
if (iscall) {
call <- expr
} else {
call <- match.call()[["expr"]]
}
len <- length(call)
if (len == 1) {
@karthik
karthik / session_info.R
Created September 8, 2016 01:09
My example Rmd and session_info
> session_info()
Session info ------------------------------------------------------
setting value
version R version 3.3.1 (2016-06-21)
system x86_64, darwin13.4.0
ui RStudio (1.0.5)
language (EN)
collate en_US.UTF-8
tz America/Los_Angeles
date 2016-09-07
@karthik
karthik / fisheries.R
Last active August 16, 2016 16:40
Getting fisheries data
library(rfisheries)
library(dplyr)
slist <- of_species_codes()
# This function fails with NULL quietly when there is no data for a particular species.
# However, if there is data, it will return the landings information
land_data <- dplyr::failwith(NULL, of_landings, quiet = TRUE)
# e.g.
# land_data(species = "COD")
# will work
@karthik
karthik / flatten_json.R
Created June 27, 2016 14:28
flatten_json.R
# This example shows you how to turn a JSON (and nested JSON)
# response into a data.frame for further use in a R package
sample_response <- '{
"crust": "original",
"toppings": ["cheese", "potatoes", "garlic"],
"status": "cooking",
"customer": {
"name": "Garrett",
@karthik
karthik / small.csv
Created June 17, 2016 20:38
small_csv
time sensor value
2016-05-11T12:30:01.000Z 3 0.055233707815
2016-05-11T12:30:04.000Z 3 0.050927011303
2016-05-11T12:30:07.000Z 3 0.046860631202
2016-05-11T12:30:09.000Z 3 0.044669326014
2016-05-11T12:30:11.000Z 3 0.044591875799
2016-05-11T12:30:12.000Z 4 0.047467439235
2016-05-11T12:30:14.000Z 4 0.05264906395
2016-05-11T12:30:16.000Z 4 0.052565799135
2016-05-11T12:30:20.000Z 4 0.056233105719