Skip to content

Commit

Permalink
Doc fixes [no ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbutuseless committed Oct 29, 2023
1 parent 7365385 commit ef19929
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 23 deletions.
4 changes: 2 additions & 2 deletions R/geojson.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' Default: 'string' will behave like 'geojsonsf'
#' @param type 'sf' or 'sfc'
#' @param property_promotion_lgl_as_int when promoting properties into a string,
#' should logical values beccome strings e.g. "TRUE" or integers
#' should logical values become strings e.g. "TRUE" or integers
#' e.g. "1". Default: "integer" in order to match `geojsonsf` packages
#'
#' @return named list
Expand Down Expand Up @@ -86,7 +86,7 @@ read_geojson_file <- function(filename, opts = list(), ...) {
}

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Write SF to geojson string
#' Write SF to GeoJSON string
#'
#' @param x \code{sf} object. Supports \code{sf} or \code{sfc}
#' @param filename filename
Expand Down
2 changes: 1 addition & 1 deletion R/json-opts.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ write_flag <- list(
#' means to keep numerics as numeric value and promote the \emph{container} to
#' be a \code{list} rather than an atomic vector when types are mixed. If \code{TRUE}
#' then array of mixed string/numeric types will be promoted to all
#' string values and returned as an atonic character vector. Set this to \code{TRUE}
#' string values and returned as an atomic character vector. Set this to \code{TRUE}
#' if you want to emulate the behaviour of \code{jsonlite::fromJSON()}
#' @param length1_array_asis logical. Should JSON arrays with length = 1 be
#' marked with class \code{AsIs}. Default: FALSE
Expand Down
8 changes: 4 additions & 4 deletions R/ndjson.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Parse an ndjson file to a data.frame or list
#' Parse an NDJSON file to a data.frame or list
#'
#' If reading as data.frame, each row of ndjson becomes a row in the data.frame.
#' If reading as data.frame, each row of NDJSON becomes a row in the data.frame.
#' If reading as a list, then each row becomes an element in the list.
#'
#' If parsing ndjson to a data.frame it is usually better if the json objects
#' If parsing NDJSON to a data.frame it is usually better if the json objects
#' are consistent from line-to-line. Type inference for the data.frame is done
#' during initialisation by reading through \code{nprobe} lines. Warning: if
#' there is a type-mismatch further into the file than it is probed, then you
Expand Down Expand Up @@ -59,7 +59,7 @@ read_ndjson_file <- function(filename, type = c('df', 'list'), nread = -1, nskip


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Write list or data.frame object to ndjson
#' Write list or data.frame object to NDJSON
#'
#' @inherit write_json_file
#' @param x data.frame or list
Expand Down
8 changes: 1 addition & 7 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,6 @@ read_json_str(str)
Parsing differences compared to `{jsonlite}`
=============================================================================

No 'digits' argument
-----------------------------------------------------------------------------

Numeric conversion is handled within the `yyjson` C library and is not
configuraable.


3-d arrays are parsed as multiple 2-d matrices and combined
-----------------------------------------------------------------------------
Expand All @@ -146,7 +140,7 @@ consistent within each package, but not cross-compatible between them i.e.
you cannot serialize an array in `{yyjsonr}` and re-create it exactly
using `{jsonlite}`.

The matrix handling in `{yyjsonr}` is compatible with the expectationf os GeoJSON
The matrix handling in `{yyjsonr}` is compatible with the expectations of GeoJSON
coordinate handling.

```{r}
Expand Down
25 changes: 25 additions & 0 deletions man/benchmark/benchmarks.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ res06 <- bench::mark(
ndjson = ndjson::stream_in(ndjson_filename),
jsonlite = jsonlite::stream_in(file(ndjson_filename), verbose = FALSE),
jsonify = jsonify::from_ndjson(ndjson_filename),
# arrow = arrow::read_json_arrow(ndjson_filename),
yyjsonr = yyjsonr::read_ndjson_file (ndjson_filename),
# relative = TRUE,
check = FALSE
)
```
Expand All @@ -220,6 +222,29 @@ plot(res06) + theme_bw() + theme(legend.position = 'none')
```


```{r echo=FALSE, eval=FALSE}
library(dplyr)
plot_df <- res06 %>%
mutate(package = as.character(expression)) %>%
rename(speed = `itr/sec`)
ggplot(plot_df) +
geom_col(aes(package, speed, fill = package),
position = position_dodge2(preserve = "single")) +
theme_bw(20) +
theme(legend.position = 'none') +
scale_fill_manual(values = c(rep(grey(0.5), 4), 'dodgerblue3')) +
geom_hline(yintercept = 1, color = 'red', alpha = 0.5, linetype = 2) +
labs(
x = NULL,
y = "Factor speed increase over {jsonlite}",
title = "Reading NDJSON. Speed-up compared to {jsonlite}",
subtitle = "Red line indicates reference implementation {jsonlite}"
)
```




To NDJSON File
-------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion man/opts_read_geojson.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/opts_read_json.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/read_ndjson_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/write_geojson_str.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/write_ndjson_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ef19929

Please sign in to comment.