diff --git a/revdep/.gitignore b/revdep/.gitignore deleted file mode 100644 index 346366a2..00000000 --- a/revdep/.gitignore +++ /dev/null @@ -1 +0,0 @@ -cloud.noindex/ diff --git a/revdep/README.md b/revdep/README.md deleted file mode 100644 index 17c414af..00000000 --- a/revdep/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Revdeps - -## Failed to check (1) - -|package |version |error |warning |note | -|:-------|:-------|:-----|:-------|:----| -|conos |1.4.5 |1 | | | - -## New problems (1) - -|package |version |error |warning |note | -|:------------------------------|:-------|:------|:-------|:----| -|[rbioapi](problems.md#rbioapi) |0.7.4 |__+1__ | | | - diff --git a/revdep/cran.md b/revdep/cran.md deleted file mode 100644 index 2ac1be8a..00000000 --- a/revdep/cran.md +++ /dev/null @@ -1,18 +0,0 @@ -## revdepcheck results - -We checked 1121 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. - - * We saw 1 new problems - * We failed to check 1 packages - -Issues with CRAN packages are summarised below. - -### New problems -(This reports the first line of each new failure) - -* rbioapi - checking tests ... ERROR - -### Failed to check - -* conos (NA) diff --git a/revdep/failures.md b/revdep/failures.md deleted file mode 100644 index 8e18a48f..00000000 --- a/revdep/failures.md +++ /dev/null @@ -1,78 +0,0 @@ -# conos - -
- -* Version: 1.4.5 -* GitHub: https://github.com/kharchenkolab/conos -* Source code: https://github.com/cran/conos -* Date/Publication: 2022-01-21 09:12:56 UTC -* Number of recursive dependencies: 239 - -Run `cloud_details(, "conos")` for more info - -
- -## In both - -* checking whether package ‘conos’ can be installed ... ERROR - ``` - Installation failed. - See ‘/tmp/workdir/conos/new/conos.Rcheck/00install.out’ for details. - ``` - -## Installation - -### Devel - -``` -* installing *source* package ‘conos’ ... -** package ‘conos’ successfully unpacked and MD5 sums checked -** using staged installation -** libs -g++ -std=gnu++11 -I"/opt/R/4.1.1/lib/R/include" -DNDEBUG -I'/opt/R/4.1.1/lib/R/site-library/Rcpp/include' -I'/opt/R/4.1.1/lib/R/site-library/RcppArmadillo/include' -I'/opt/R/4.1.1/lib/R/site-library/RcppEigen/include' -I'/opt/R/4.1.1/lib/R/site-library/RcppProgress/include' -I/usr/local/include -I"./include" -fopenmp -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o -In file included from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/Eigen/Core:397, - from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/Eigen/Dense:1, - from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/RcppEigenForward.h:30, - from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/RcppEigen.h:25, - from RcppExports.cpp:6: -... -*** moving datasets to lazyload DB -** inst -** byte-compile and prepare package for lazy loading -Error in dyn.load(file, DLLpath = DLLpath, ...) : - unable to load shared object '/opt/R/4.1.1/lib/R/site-library/leidenAlg/libs/leidenAlg.so': - /rspm_builder/tmp/tmp.vYZcnqsJUt/igraph/libs/igraph.so: cannot open shared object file: No such file or directory -Calls: ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load -Execution halted -ERROR: lazy loading failed for package ‘conos’ -* removing ‘/tmp/workdir/conos/new/conos.Rcheck/conos’ - - -``` -### CRAN - -``` -* installing *source* package ‘conos’ ... -** package ‘conos’ successfully unpacked and MD5 sums checked -** using staged installation -** libs -g++ -std=gnu++11 -I"/opt/R/4.1.1/lib/R/include" -DNDEBUG -I'/opt/R/4.1.1/lib/R/site-library/Rcpp/include' -I'/opt/R/4.1.1/lib/R/site-library/RcppArmadillo/include' -I'/opt/R/4.1.1/lib/R/site-library/RcppEigen/include' -I'/opt/R/4.1.1/lib/R/site-library/RcppProgress/include' -I/usr/local/include -I"./include" -fopenmp -fpic -g -O2 -c RcppExports.cpp -o RcppExports.o -In file included from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/Eigen/Core:397, - from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/Eigen/Dense:1, - from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/RcppEigenForward.h:30, - from /opt/R/4.1.1/lib/R/site-library/RcppEigen/include/RcppEigen.h:25, - from RcppExports.cpp:6: -... -*** moving datasets to lazyload DB -** inst -** byte-compile and prepare package for lazy loading -Error in dyn.load(file, DLLpath = DLLpath, ...) : - unable to load shared object '/opt/R/4.1.1/lib/R/site-library/leidenAlg/libs/leidenAlg.so': - /rspm_builder/tmp/tmp.vYZcnqsJUt/igraph/libs/igraph.so: cannot open shared object file: No such file or directory -Calls: ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load -Execution halted -ERROR: lazy loading failed for package ‘conos’ -* removing ‘/tmp/workdir/conos/old/conos.Rcheck/conos’ - - -``` diff --git a/revdep/notes.md b/revdep/notes.md deleted file mode 100644 index 95a8ae37..00000000 --- a/revdep/notes.md +++ /dev/null @@ -1,18 +0,0 @@ -# Failure Notes - -|Package | Failure reason | -|:--------------|:----------------------------------| -| ChemoSpec | Unavailable dependency `speaq` | -| curl | Network issue | -| dismo | Needs Java | -| fitbitScraper | CRAN checks with `--no-vignettes` | -| futile.logger | Fails on CRAN | -| ggvis | Fails on CRAN | -| h2o | Needs Java | -| httr | Network issue | -| hypothesisr | Fails on CRAN | -| ndtv | Needs Java | -| trelliscope | Needs Java | -| webchem | Needs Java | -| x.ent | Needs Java | - diff --git a/revdep/problems.md b/revdep/problems.md deleted file mode 100644 index 8f013850..00000000 --- a/revdep/problems.md +++ /dev/null @@ -1,38 +0,0 @@ -# rbioapi - -
- -* Version: 0.7.4 -* GitHub: https://github.com/moosa-r/rbioapi -* Source code: https://github.com/cran/rbioapi -* Date/Publication: 2021-06-22 08:00:01 UTC -* Number of recursive dependencies: 57 - -Run `cloud_details(, "rbioapi")` for more info - -
- -## Newly broken - -* checking tests ... ERROR - ``` - Running ‘testthat.R’ - Running the tests in ‘tests/testthat.R’ failed. - Last 13 lines of output: - ── Failure (test-api_calls_rba_skeleton.R:13:3): .rba_skeleton works ─────────── - Your object's class is `character`` but `response`` is expected. - ── Error (test-api_calls_rba_skeleton.R:36:3): .rba_skeleton works ───────────── - Error: The server returned HTTP Status '403' (Redirection: Forbidden). - Backtrace: - ▆ - 1. ├─testthat::expect_null(object = .rba_skeleton(input_call = request)) at test-api_calls_rba_skeleton.R:36:2 - 2. │ └─testthat::quasi_label(enquo(object), label, arg = "object") - 3. │ └─rlang::eval_bare(expr, quo_get_env(quo)) - 4. └─rbioapi:::.rba_skeleton(input_call = request) - 5. └─rbioapi:::.rba_api_call(...) - - [ FAIL 4 | WARN 0 | SKIP 0 | PASS 113 ] - Error: Test failures - Execution halted - ``` - diff --git a/stuff/benchmark.R b/stuff/benchmark.R deleted file mode 100644 index 6fd24e49..00000000 --- a/stuff/benchmark.R +++ /dev/null @@ -1,26 +0,0 @@ -library(jsonlite) -library(microbenchmark) - -# medium dataset: 53940 x 10 = 0.54M values -data(diamonds, package="ggplot2") -dmd_rows <- toJSON(diamonds) -dmd_cols <- toJSON(diamonds, dataframe = "columns") -microbenchmark( - toJSON(diamonds), #0.60 - toJSON(diamonds, dataframe = "columns"), #0.32 - fromJSON(dmd_rows), #1.15 - fromJSON(dmd_cols), # 0.41 - times=10 -) - -# larger dataset: 227496 x 21 = 4.7M values -data(hflights, package="hflights") -hfl_rows <- toJSON(hflights) -hfl_cols <- toJSON(hflights, dataframe="columns") -microbenchmark( - toJSON(hflights), #4.92 - toJSON(hflights, dataframe = "columns"), #2.80 - fromJSON(hfl_rows), #12.30 - fromJSON(hfl_cols), #4.02 - times=5 -) diff --git a/stuff/comparison.Rmd b/stuff/comparison.Rmd deleted file mode 100644 index cc4bc14e..00000000 --- a/stuff/comparison.Rmd +++ /dev/null @@ -1,156 +0,0 @@ ---- -title: "A biased comparsion of JSON packages in R" -output: html_document ---- - -```{r echo=FALSE, message=FALSE} -library(knitr) -opts_chunk$set(comment="") -options(width = 120) -#make sure we compare most recent versions -stopifnot(packageVersion("rjson") >= "0.2.14") -stopifnot(packageVersion("RJSONIO") >= "1.3-0") -stopifnot(packageVersion("jsonlite") >= "0.9.12") -``` - -Some simple examples to compare behavior and performance of JSON packages in R. - -### Data frame - -```{r} -all.equal(mtcars, rjson::fromJSON(rjson::toJSON(mtcars))) -all.equal(mtcars, RJSONIO::fromJSON(RJSONIO::toJSON(mtcars))) -all.equal(mtcars, jsonlite::fromJSON(jsonlite::toJSON(mtcars))) -``` - -### Matrix - -```{r} -(x <- matrix(1:6, 2)) -rjson::fromJSON(rjson::toJSON(x)) -RJSONIO::fromJSON(RJSONIO::toJSON(x)) -jsonlite::fromJSON(jsonlite::toJSON(x)) -``` - -### Lists - -```{r} -x <- list(foo = 123, bar= 456) -rjson::fromJSON(rjson::toJSON(x)) -RJSONIO::fromJSON(RJSONIO::toJSON(x)) -jsonlite::fromJSON(jsonlite::toJSON(x)) -``` - -### Missing values - -```{r} -rjson::fromJSON(rjson::toJSON(c(1,2,NA,4))) -RJSONIO::fromJSON(RJSONIO::toJSON(c(1,2,NA,4))) -jsonlite::fromJSON(jsonlite::toJSON(c(1,2,NA,4))) -``` - -### Escaping - -```{r} -x <- list("\b\f\n\r\t" = "\b\f\n\r\t") -identical(x, rjson::fromJSON(rjson::toJSON(x))) -identical(x, RJSONIO::fromJSON(RJSONIO::toJSON(x))) -identical(x, jsonlite::fromJSON(jsonlite::toJSON(x))) -``` - -### Parser error handling - -```{r, error=TRUE} -rjson::fromJSON('[1,2,boo",4]') -RJSONIO::fromJSON('[1,2,boo",4]') -jsonlite::fromJSON('[1,2,boo",4]') -``` - -### Unicode - -```{r, error=TRUE} -json = '["\\u5bff\u53f8","Z\\u00fcrich", "\\u586B"]' -rjson::fromJSON(json) -RJSONIO::fromJSON(json) -jsonlite::fromJSON(json) -``` - -### Prettify, validate - -Only RJSONIO and jsonlite have functionality to validate or prettify JSON: - -```{r} -x <- list(foo = c("hi", "hello"), bar=1:3) -cat(RJSONIO::toJSON(x, pretty = TRUE)) -cat(jsonlite::toJSON(x, pretty = TRUE)) -RJSONIO::isValidJSON(RJSONIO::toJSON(x), asText = TRUE) -jsonlite::validate(jsonlite::toJSON(x)) -``` - -### Digits - -RJSONIO uses significant digits, whereas jsonlite uses decimal digits. rjson does not support this. - -```{r} -rjson::toJSON(pi) -RJSONIO::toJSON(pi, digits=4) -jsonlite::toJSON(pi, digits=4) -``` - - -### Controlling simplification - -Only RJSONIO and jsonlite give control over vector simplification. rjson always simplifies if possible. - -```{r} -json <- '[1,2,3,4]' -RJSONIO::fromJSON(json) -RJSONIO::fromJSON(json, simplify = FALSE) -jsonlite::fromJSON(json) -jsonlite::fromJSON(json, simplifyVector = FALSE) -rjson::fromJSON(json) -``` - -### Performance 1: generating JSON - -Comparing performance is a bit difficult because different packages do different things. The `rjson` package has no options to control conversion, so the only way to benchmark common functionality is by trying to mimic `rjson`: - -```{r} -library(microbenchmark) -data(diamonds, package="ggplot2") -microbenchmark( - rjson::toJSON(diamonds), - RJSONIO::toJSON(diamonds), - jsonlite::toJSON(diamonds, dataframe = "column"), - times = 10 -) -``` - -What if we throw some missing values in the mix: - -```{r} -diamonds2 <- diamonds -diamonds2[1,] <- NA; -microbenchmark( - rjson::toJSON(diamonds2), - RJSONIO::toJSON(diamonds2), - jsonlite::toJSON(diamonds2, dataframe = "column"), - times = 10 -) -``` - -### Performance 2: Parsing JSON - -For parsing, comparing performance gets even trickier because rjson does not give any control over simplification. The following settings in RJSONIO and jsonlite are roughly equivalent to rjson: - -```{r} -json <- rjson::toJSON(diamonds) -microbenchmark( - rjson::fromJSON(json), - RJSONIO::fromJSON(json, simplifyWithNames=FALSE), - jsonlite::fromJSON(json, simplifyDataFrame = FALSE, simplifyMatrix = FALSE), - times = 10 -) -``` - - diff --git a/stuff/comparison.html b/stuff/comparison.html deleted file mode 100644 index 406de222..00000000 --- a/stuff/comparison.html +++ /dev/null @@ -1,324 +0,0 @@ - - - - - - - - - - - - -A biased comparsion of JSON packages in R - - - - - - - - - - - - - - - - - - - - -
- - - - - -

Some simple examples to compare behavior and performance of JSON packages in R.

-
-

Data frame

-
all.equal(mtcars, rjson::fromJSON(rjson::toJSON(mtcars)))
-
[1] "Attributes: < names for target but not for current >"             
-[2] "Attributes: < Length mismatch: comparison on first 0 components >"
-
all.equal(mtcars, RJSONIO::fromJSON(RJSONIO::toJSON(mtcars)))
-
[1] "Attributes: < names for target but not for current >"             
-[2] "Attributes: < Length mismatch: comparison on first 0 components >"
-
all.equal(mtcars, jsonlite::fromJSON(jsonlite::toJSON(mtcars)))
-
[1] TRUE
-
-
-

Matrix

-
(x <- matrix(1:6, 2))
-
     [,1] [,2] [,3]
-[1,]    1    3    5
-[2,]    2    4    6
-
rjson::fromJSON(rjson::toJSON(x))
-
[1] 1 2 3 4 5 6
-
RJSONIO::fromJSON(RJSONIO::toJSON(x))
-
[[1]]
-[1] 1 3 5
-
-[[2]]
-[1] 2 4 6
-
jsonlite::fromJSON(jsonlite::toJSON(x))
-
     [,1] [,2] [,3]
-[1,]    1    3    5
-[2,]    2    4    6
-
-
-

Lists

-
x <- list(foo = 123, bar= 456)
-rjson::fromJSON(rjson::toJSON(x))
-
$foo
-[1] 123
-
-$bar
-[1] 456
-
RJSONIO::fromJSON(RJSONIO::toJSON(x))
-
foo bar 
-123 456 
-
jsonlite::fromJSON(jsonlite::toJSON(x))
-
$foo
-[1] 123
-
-$bar
-[1] 456
-
-
-

Missing values

-
rjson::fromJSON(rjson::toJSON(c(1,2,NA,4)))
-
[[1]]
-[1] 1
-
-[[2]]
-[1] 2
-
-[[3]]
-[1] "NA"
-
-[[4]]
-[1] 4
-
RJSONIO::fromJSON(RJSONIO::toJSON(c(1,2,NA,4)))
-
[[1]]
-[1] 1
-
-[[2]]
-[1] 2
-
-[[3]]
-NULL
-
-[[4]]
-[1] 4
-
jsonlite::fromJSON(jsonlite::toJSON(c(1,2,NA,4)))
-
[1]  1  2 NA  4
-
-
-

Escaping

-
x <- list("\b\f\n\r\t" = "\b\f\n\r\t")
-identical(x, rjson::fromJSON(rjson::toJSON(x)))
-
[1] TRUE
-
identical(x, RJSONIO::fromJSON(RJSONIO::toJSON(x)))
-
[1] FALSE
-
identical(x, jsonlite::fromJSON(jsonlite::toJSON(x)))
-
[1] TRUE
-
-
-

Parser error handling

-
rjson::fromJSON('[1,2,boo",4]')
-
Error: unexpected character 'b'
-
RJSONIO::fromJSON('[1,2,boo",4]')
-
[[1]]
-[1] 1
-
-[[2]]
-[1] 2
-
-[[3]]
-NULL
-
jsonlite::fromJSON('[1,2,boo",4]')
-
Error: lexical error: invalid char in json text.
-                                  [1,2,boo",4]
-                     (right here) ------^
-
-
-

Unicode

-
json = '["\\u5bff\u53f8","Z\\u00fcrich", "\\u586B"]'
-rjson::fromJSON(json)
-
[1] "寿司"   "Zürich" "填"    
-
RJSONIO::fromJSON(json)
-
[1] "\xff司"    "Z\xfcrich" "k"        
-
jsonlite::fromJSON(json)
-
[1] "寿司"   "Zürich" "填"    
-
-
-

Prettify, validate

-

Only RJSONIO and jsonlite have functionality to validate or prettify JSON:

-
x <- list(foo = c("hi", "hello"), bar=1:3)
-cat(RJSONIO::toJSON(x, pretty = TRUE))
-
{
-    "foo" : [
-        "hi",
-        "hello"
-    ],
-    "bar" : [
-        1,
-        2,
-        3
-    ]
-}
-
cat(jsonlite::toJSON(x, pretty = TRUE))
-
{
-    "foo": [
-        "hi",
-        "hello"
-    ],
-    "bar": [
-        1,
-        2,
-        3
-    ]
-}
-
RJSONIO::isValidJSON(RJSONIO::toJSON(x), asText = TRUE)
-
[1] TRUE
-
jsonlite::validate(jsonlite::toJSON(x))
-
[1] TRUE
-
-
-

Digits

-

RJSONIO uses significant digits, whereas jsonlite uses decimal digits. rjson does not support this.

-
rjson::toJSON(pi)
-
[1] "3.14159265358979"
-
RJSONIO::toJSON(pi, digits=4)
-
[1] "[ 3.142 ]"
-
jsonlite::toJSON(pi, digits=4)
-
[3.1416] 
-
-
-

Controlling simplification

-

Only RJSONIO and jsonlite give control over vector simplification. rjson always simplifies if possible.

-
json <- '[1,2,3,4]'
-RJSONIO::fromJSON(json)
-
[1] 1 2 3 4
-
RJSONIO::fromJSON(json, simplify = FALSE)
-
[[1]]
-[1] 1
-
-[[2]]
-[1] 2
-
-[[3]]
-[1] 3
-
-[[4]]
-[1] 4
-
jsonlite::fromJSON(json)
-
[1] 1 2 3 4
-
jsonlite::fromJSON(json, simplifyVector = FALSE)
-
[[1]]
-[1] 1
-
-[[2]]
-[1] 2
-
-[[3]]
-[1] 3
-
-[[4]]
-[1] 4
-
rjson::fromJSON(json)
-
[1] 1 2 3 4
-
-
-

Performance 1: generating JSON

-

Comparing performance is a bit difficult because different packages do different things. The rjson package has no options to control conversion, so the only way to benchmark common functionality is by trying to mimic rjson:

-
library(microbenchmark)
-data(diamonds, package="ggplot2")
-microbenchmark(
-  rjson::toJSON(diamonds),
-  RJSONIO::toJSON(diamonds),
-  jsonlite::toJSON(diamonds, dataframe = "column"),
-  times = 10
-)
-
Unit: milliseconds
-                                             expr   min    lq median    uq   max neval
-                          rjson::toJSON(diamonds) 291.3 291.9  303.2 321.1 368.3    10
-                        RJSONIO::toJSON(diamonds) 834.8 850.3  881.1 892.4 973.5    10
- jsonlite::toJSON(diamonds, dataframe = "column") 314.8 318.5  333.7 350.5 375.5    10
-

What if we throw some missing values in the mix:

-
diamonds2 <- diamonds
-diamonds2[1,] <- NA;
-microbenchmark(
-  rjson::toJSON(diamonds2),
-  RJSONIO::toJSON(diamonds2),
-  jsonlite::toJSON(diamonds2, dataframe = "column"),
-  times = 10
-)
-
Unit: milliseconds
-                                              expr    min     lq median     uq    max neval
-                          rjson::toJSON(diamonds2)  291.4  292.2  293.8  295.1  301.0    10
-                        RJSONIO::toJSON(diamonds2) 1482.6 1521.9 1544.2 1564.8 1597.6    10
- jsonlite::toJSON(diamonds2, dataframe = "column")  314.0  317.9  321.4  330.0  397.6    10
-
-
-

Performance 2: Parsing JSON

-

For parsing, comparing performance gets even trickier because rjson does not give any control over simplification. The following settings in RJSONIO and jsonlite are roughly equivalent to rjson:

-
json <- rjson::toJSON(diamonds)
-microbenchmark(
-  rjson::fromJSON(json),
-  RJSONIO::fromJSON(json, simplifyWithNames=FALSE),
-  jsonlite::fromJSON(json, simplifyDataFrame = FALSE, simplifyMatrix = FALSE),
-  times = 10
-)
-
Unit: milliseconds
-                                                                        expr    min    lq median    uq   max neval
-                                                       rjson::fromJSON(json)  99.65 101.2  102.4 109.7 147.8    10
-                          RJSONIO::fromJSON(json, simplifyWithNames = FALSE) 415.56 417.8  422.3 454.6 477.1    10
- jsonlite::fromJSON(json, simplifyDataFrame = FALSE, simplifyMatrix = FALSE) 180.46 189.7  198.5 238.1 278.5    10
-
- - -
- - - - - - - - diff --git a/stuff/fromBSON.R b/stuff/fromBSON.R deleted file mode 100644 index acf04a6f..00000000 --- a/stuff/fromBSON.R +++ /dev/null @@ -1,37 +0,0 @@ -#' Convert a mongo.bson object to an R object. -#' -#' This function uses \code{mongo.bson.to.list} from the \code{rmongodb} package -#' to read a \code{BSON} object, and then uses \code{jsonlite} the same mapping as for -#' \code{JSON} objects to convert it into an R object. -#' -#' @param b A \code{mongo.bson} object. Passed to \code{mongo.bson.to.list}. See package \code{rmongodb}. -#' @param simplifyVector coerse JSON arrays containing only scalars into a vector -#' @param simplifyDataFrame coerse JSON arrays containing only records (JSON objects) into a data frame. -#' @param simplifyMatrix coerse JSON arrays containing vectors of equal length and mode into matrix or array. -#' @param ... arguments passed on to class specific \code{print} methods -#' @export -fromBSON <- function(b, simplifyVector = TRUE, simplifyDataFrame = simplifyVector, - simplifyMatrix = simplifyVector, ...){ - - #load rmongodb if not loaded - obj <- rmongodb::mongo.bson.to.list(b) - - # post processing - if (any(isTRUE(simplifyVector), isTRUE(simplifyDataFrame), isTRUE(simplifyMatrix))) { - return(simplify(obj, simplifyVector = simplifyVector, simplifyDataFrame = simplifyDataFrame, - simplifyMatrix = simplifyMatrix, ...)) - } else { - return(obj) - } -} - -mongoquery <- function(mongo, ns, ...){ - cursor <- mongo.find(mongo, ns, ...); - results <- list(); - while (mongo.cursor.next(cursor)) { - b <- mongo.cursor.value(cursor); - results[[length(results)+1]] <- mongo.bson.to.list(b); - } - jsonlite:::simplify(results) -} - diff --git a/stuff/mongo.R b/stuff/mongo.R deleted file mode 100644 index a0df59b6..00000000 --- a/stuff/mongo.R +++ /dev/null @@ -1,10 +0,0 @@ -library(rmongodb) -library(jsonlite) - -x1 <- fromJSON("https://api.github.com/users/hadley/repos") -m <- mongo.create(); -table <- "test.mydata" -mongo.remove(m, table) -jsonlite:::mongo_write(x1, m, table, pagesize = 10, na="null") -x2 <- jsonlite:::mongo_read(m, table, pagesize = 5) -identical(x1, x2) diff --git a/stuff/parseTimestamp.R b/stuff/parseTimestamp.R deleted file mode 100644 index d97d6f85..00000000 --- a/stuff/parseTimestamp.R +++ /dev/null @@ -1,50 +0,0 @@ -# timestamps can either be: ISO8601 (various formats), R style print, GMT epoch -# ms, or mongo - -parseTimestamp <- function(x) { - UseMethod("parseTimestamp") -} - -#' @method parseTimestamp numeric -parseTimestamp.numeric <- function(x) { - if (any(x < 1e+10) && all(x < 1e+10)) { - warning("Timestamps seem low. Make sure they are milliseconds and not seconds:\n\n", - x) - } - structure(x/1000, class = c("POSIXct", "POSIXt")) -} - -#' @method parseTimestamp character -parseTimestamp.character <- function(x) { - if (length(na.omit(x)) == 0) { - return(x) - } - - patterns <- list(ISODATE = "^(\\d{4})-(\\d{2})-(\\d{2})$", ISOTIME = "^(\\d{4})-(\\d{2})-(\\d{2})(T|\\s)(\\d{2}):(\\d{2})$", - ISOTIMEUTC = "^(\\d{4})-(\\d{2})-(\\d{2})(T|\\s)(\\d{2}):(\\d{2})Z$", ISOTIMESECONDS = "^(\\d{4})-(\\d{2})-(\\d{2})(T|\\s)(\\d{2}):(\\d{2}):(\\d{2})$", - ISOTIMESECONDSUTC = "^(\\d{4})-(\\d{2})-(\\d{2})(T|\\s)(\\d{2}):(\\d{2}):(\\d{2})Z$") - - patsums <- sapply(lapply(patterns, regexpr, x), sum, na.rm = TRUE) - if (max(patsums) == 0) { - stop("Dates in invalid format:\n", x) - } - datepattern <- names(patterns[which.max(patsums)]) - - # bit more lenient than iso 8601: we accept both T and space - substring(x, 11) <- "T" - - # select format - outtime <- switch(datepattern, ISODATE = strptime(x, "%Y-%m-%d"), ISOTIME = strptime(x, - "%Y-%m-%dT%H:%M"), ISOTIMEUTC = strptime(x, "%Y-%m-%dT%H:%MZ", tz = "UTC"), - ISOTIMESECONDS = strptime(x, "%Y-%m-%dT%H:%M:%S"), ISOTIMESECONDSUTC = strptime(x, - "%Y-%m-%dT%H:%M:%SZ", tz = "UTC"), ) - - # convert to POSIXct - outtime <- as.POSIXct(outtime) - - # return - return(outtime) -} - -#' @method parseTimestamp POSIXt -parseTimestamp.POSIXt <- identity diff --git a/stuff/profile.R b/stuff/profile.R deleted file mode 100644 index 1dde9b07..00000000 --- a/stuff/profile.R +++ /dev/null @@ -1,10 +0,0 @@ -#install_github("jeroenooms/lineprof) -library(lineprof) -library(jsonlite) - -data(hflights, package="hflights") -l1 <- lineprof(json <- toJSON(hflights)) -l2 <- lineprof(fromJSON(json)) - -summary(l1, 8) -summary(l2, 8) diff --git a/stuff/stream_io.R b/stuff/stream_io.R deleted file mode 100644 index 2aa5429b..00000000 --- a/stuff/stream_io.R +++ /dev/null @@ -1,18 +0,0 @@ -library(jsonlite) - -# Full JSON stream IO: stream from URL to file. -# Calculate delays for flights over 1000 miles in batches of 5k -library(dplyr) -con_in <- gzcon(url("http://jeroen.github.io/data/nycflights13.mjson.gz")) -con_out <- file(tmp <- tempfile(), open = "w") -stream_in(con_in, handler = function(df){ - df <- dplyr::filter(df, distance > 1000) - df <- dplyr::mutate(df, delta = dep_delay - arr_delay) - stream_out(df, con_out, pagesize = 1000) -}, pagesize = 5000) -close(con_out) - -# stream it back in -mydata <- stream_in(file(tmp)) -nrow(mydata) -unlink(tmp)