- Only accepted if R CMD CHECK passes with no WARNINGS or ERRORs
- Long-term archive, and difficult to remove
- Provides registry of R packages
- Zenodo DOIs
This file contains 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(httr) | |
library(jsonlite) | |
find_endorsements <- function(x) { | |
r <- GET("https://www.linkedin.com/ta/skill" ,query = list(query = x)) | |
stop_for_status(r) | |
json <- content(r, "parsed") | |
vapply(json$resultList, "[[", "displayName", FUN.VALUE = character(1)) |
This file contains 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
#include <Rcpp.h> | |
using namespace Rcpp; | |
// [[Rcpp::export]] | |
std::string escape_one(std::string x) { | |
int n = x.size(); | |
std::string out = "\""; | |
out.reserve(n + 2); | |
for (int i = 0; i < n; ++i) { |
This file contains 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
iclass <- function(x) { | |
c( | |
if (is.matrix(x)) "matrix", | |
if (is.array(x) && !is.matrix(x)) "array", | |
if (is.double(x)) "double", | |
if (is.integer(x)) "integer", | |
mode(x) | |
) | |
} |
This file contains 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
`[.my_df` <- function (x, i, j) { | |
if (missing(i) && missing(j)) return(x) | |
# First, subset columns | |
if (!missing(j)) { | |
x <- .subset(x, j) | |
} | |
# Next, subset rows | |
if (!missing(i)) { |
This file contains 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("stringi") | |
ref <- ISOdatetime(2006, 01, 02, 15, 4, 0, "MST") | |
formats <- c("%H", "%Y", "%y", "%b", "%B", "%m", "%d", "%e", "%a", | |
"%A", "%I", "%l", "%p", "%Z", "%z", "%M", "%S") | |
# Must manually respecify TZ because strftime doesn't use the time zone | |
# stored in ref | |
conv <- vapply(formats, function(x) strftime(ref, x, tz = "MST"), character(1)) |
This file contains 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(stringi) | |
locales <- stri_locale_list() | |
main <- locales[!stri_detect_fixed(locales, "_")] | |
main_col <- lapply(main, stri_opts_collator) | |
sorted <- lapply(main_col, function(x) stri_sort(letters, opts_collator = x)) | |
names(sorted) <- main | |
noquote(simplify2array(Filter(function(x) !identical(x, letters), sorted))) |
This file contains 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(class) | |
library(mass) | |
library(mva) | |
tst <- read.table("e:/uni/stats766/puktest.txt", header = TRUE) | |
tst.v <- tst[,1:7] | |
tst.g <- tst[,8] | |
trn <- read.table("e:/uni/stats766/puktrain.txt", header = TRUE) | |
trn.v <- trn[,1:7] | |
trn.g <- trn[,8] |
This file contains 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
data_sort <- function() { | |
desc <- FALSE; | |
my_sort <- function (data) { | |
sort(data, decreasing = desc) | |
} | |
attr(my_sort, "desc") <- function(x) { | |
desc <<- x | |
return(my_sort) |
This file contains 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
# http://stackoverflow.com/a/3407254/16632 | |
Rcpp::cppFunction("double ceil_any(double x, double prec) { | |
if (fabs(prec / x) < DBL_MIN) | |
return x; | |
double r = fmod(fabs(x), prec); | |
if (r == 0) | |
return x; | |
return (x > 0) ? x + prec - r : x + r; |