Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Old pr #108

Merged
merged 47 commits into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
6f9c73d
Add drop fix.
colearendt Apr 23, 2017
55220a1
Add direct support for NSE dplyr verbs
colearendt May 14, 2017
e190f42
Add failing test for path with vector input
colearendt May 15, 2017
96ce780
Initial commit on multiple-apis vignette
colearendt May 15, 2017
9b7a965
Add appveyor support using devtools::use_appveyor()
colearendt May 2, 2017
ecb0c1b
Add packrat
colearendt May 19, 2017
1634b33
Add bind_rows support
colearendt May 19, 2017
27e50f1
Skip print tests
colearendt May 21, 2017
9a70a20
Add revdep
colearendt May 22, 2017
6d6b2aa
Improve vignettes and docs
colearendt May 24, 2017
4464ff0
Update docs
colearendt May 29, 2017
587734f
Update packrat.lock
colearendt May 29, 2017
64e361b
Fix spread_all recursive=FALSE
colearendt May 29, 2017
3ed3d07
Handle errors in print
colearendt May 29, 2017
392dc6a
Turn spread_all name dedupe into loop
colearendt May 30, 2017
b877d83
Change naming of j* functions to purrr
colearendt May 30, 2017
43496cb
Update docs, NEWS.md, vignettes, NAMESPACE
colearendt May 30, 2017
4ffec9d
Fix json_structure
colearendt Jun 2, 2017
34624aa
Impute document.id instead of bypass it
colearendt Jun 2, 2017
aaf1f3c
Update vignette and NEWS
colearendt Jun 2, 2017
9e2a4a6
.travis.yml config
colearendt Jun 10, 2017
f7f767b
Add tests for new functionality
colearendt Jun 11, 2017
d15e7ae
Deprecate append_values_* family
colearendt Jun 11, 2017
47b458c
Update docs
colearendt Jun 11, 2017
f6f13f4
Convert tbl_df to as_tibble
colearendt Jun 12, 2017
168b4d7
Merge pull request #3 from colearendt/developclean
colearendt Jun 15, 2017
81b00a4
Update badges
colearendt Aug 19, 2017
91167bf
Append_values undo rename
colearendt Aug 19, 2017
e5ed7c7
Undo is_json and json_ renames
colearendt Aug 19, 2017
a4f9222
Add osx builds
colearendt Aug 19, 2017
5cdc59f
Merge pull request #4 from colearendt/feature/fix_naming
colearendt Aug 20, 2017
d661b42
Merge pull request #5 from colearendt/develop
colearendt Aug 26, 2017
80fc449
ignore tests incompatible with tibble
colearendt Mar 8, 2019
2609fb8
update description and namespace
colearendt Mar 9, 2019
c31ec4c
update as_tibble method
colearendt Mar 9, 2019
75e8d4e
remove needs package
colearendt Mar 9, 2019
1249863
update docs
colearendt Mar 9, 2019
fabb44c
update readme references to colearendt
colearendt Mar 9, 2019
9b9b819
update readme render
colearendt Mar 9, 2019
13f9584
remove needs as a dependency
colearendt Mar 9, 2019
2c9d465
update news
colearendt Mar 9, 2019
080e957
update url and bugreports
colearendt Mar 9, 2019
6ad1302
update authors description
colearendt Mar 9, 2019
3aa67c0
update license
colearendt Mar 9, 2019
770f3f4
add more clear license
colearendt Mar 9, 2019
447dfbf
buildignore the license.md
colearendt Mar 9, 2019
523a938
update news links
colearendt Mar 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
^LICENSE\.md$
^\.travis\.yml$
^cran-comments\.md$
^.*\.Rproj$
^\.Rproj\.user$
^codecov\.yml$
^README\.Rmd$
^README-.*\.png$
^packrat/
^\.Rprofile$
^working/
^appveyor\.yml$
^revdep/
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text=auto
data/* binary
src/* text=lf
R/* text=lf
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ inst/doc
.Rproj.user
*.Rproj
.DS_Store
packrat/lib*/
packrat/src/
working/
.Rprofile
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,29 @@ language: R
sudo: false
cache: packages

os:
- linux
- osx

r:
- oldrel
- release
- devel

matrix:
allow_failures:
- r: devel

r_packages:
- covr

script:
- |
travis_wait 60 R CMD build --no-build-vignettes --no-manual --no-resave-data .
travis_wait 60 R CMD check --no-build-vignettes --no-manual tidyjson*tar.gz

after_success:
- Rscript -e 'library(covr); codecov()'

after_script:
- ./travis-tool.sh dump_logs
18 changes: 10 additions & 8 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Package: tidyjson
Title: Tidy Complex JSON
Version: 0.2.1.9000
Author: Jeremy Stanley <[email protected]>
Maintainer: Jeremy Stanley <[email protected]>
Version: 0.2.1.9001
Authors@R: c(
person("Jeremy", "Stanley", , "[email protected]", c("aut")),
person("Cole", "Arendt", , "[email protected]", c("aut", "cre"))
)
Description: Turn complex JSON data into tidy data frames.
Depends:
R (>= 3.1.0)
Expand All @@ -21,15 +23,15 @@ Suggests:
testthat,
ggplot2,
rmarkdown,
needs,
forcats,
wordcloud,
viridis,
listviewer,
igraph,
RColorBrewer,
covr
covr,
lubridate
VignetteBuilder: knitr
URL: https://github.com/jeremystan/tidyjson
BugReports: https://github.com/jeremystan/tidyjson/issues
RoxygenNote: 5.0.1
URL: https://github.com/colearendt/tidyjson
BugReports: https://github.com/colearendt/tidyjson/issues
RoxygenNote: 6.1.1
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2016
COPYRIGHT HOLDER: Jeremy Stanley
YEAR: 2019
COPYRIGHT HOLDER: Jeremy Stanley, Cole Arendt
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# MIT License

Copyright (c) 2019 Jeremy Stanley, Cole Arendt

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
# Generated by roxygen2: do not edit by hand

S3method("[",tbl_json)
S3method(arrange,tbl_json)
S3method(arrange_,tbl_json)
S3method(as.character,tbl_json)
S3method(as.tbl_json,character)
S3method(as.tbl_json,data.frame)
S3method(as.tbl_json,tbl_json)
S3method(as_tibble,tbl_json)
S3method(filter,tbl_json)
S3method(filter_,tbl_json)
S3method(mutate,tbl_json)
S3method(mutate_,tbl_json)
S3method(print,tbl_json)
S3method(slice,tbl_json)
S3method(slice_,tbl_json)
export("%>%")
export(append_values_logical)
export(append_values_number)
export(append_values_string)
export(as.tbl_json)
export(as_data_frame)
export(as_tibble)
export(bind_rows)
export(enter_object)
export(gather_array)
export(gather_keys)
Expand Down
35 changes: 31 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
# purrr 0.2.1.9000
# tidyjson 0.2.1.9001

## New functions

* Add `bind_rows()` support. Though currently not an S3 implementation, it behaves as much like the `dplyr` variant as possible, preserving the `attr(.,'JSON')` components if all components are `tbl_json` objects. (#58)

## Documentation Changes

* "Using Multiple APIs" vignette added to show support for using tidyjson with multiple APIs (#85)

* Updated README.md to better explain `spread_all()` (#92)

## Bug fixes and minor changes

* `DROP=TRUE` caused an error. Altered behavior to be consistent with `tbl_df`

* Fix `spread_all(recursive=FALSE)` bug that caused an error (#65)

* Alter `spread_all()` behavior to recursively check for deduplication of names (and thus avoid an error) (#76)

* Add named support for the `NSE` versions of dplyr functions (`filter()`,`mutate()`,`slice()`, etc.) since the `SE` variants are no longer called behind-the-scenes since `dplyr 0.6.0`. (#97)

* Fix errors with `print.tbl_json()` when the JSON attribute is missing

* Fix json_structure() failure if `document.id` missing by imputing
the missing `document.id`. (#86)

# tidyjson 0.2.1.9000

## New functions

Expand Down Expand Up @@ -30,9 +57,9 @@

* `tbl_json` objects now print with a tidy character representation of the JSON attribute (#61)

* Use [purrr](https://github.com/jeremystan/purrr) for most list based internal operations (#1)
* Use [purrr](https://github.com/tidyverse/purrr) for most list based internal operations (#1)

* Use [tidyr](https://github.com/hadley/tidyr) for `gather_array` and `gather_object` functions (#28)
* Use [tidyr](https://github.com/tidyverse/tidyr) for `gather_array` and `gather_object` functions (#28)

* Imported the magrittr `%>%` operator (#17)

Expand All @@ -46,7 +73,7 @@

## Other changes

* Migrated development to [jeremystan](https://github.com/jeremystan/tidyjson) from [sailthru](https://github.com/sailthru/tidyjson)
* Migrated development to [colearendt](https://github.com/colearendt/tidyjson) from [jeremystan](https://github.com/jeremystan/tidyjson) and [sailthru](https://github.com/sailthru/tidyjson)

## Deprecated functions

Expand Down
8 changes: 4 additions & 4 deletions R/append_values.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ append_values_factory <- function(type, as.value) {

if (!is.tbl_json(.x)) .x <- as.tbl_json(.x)

if (force == FALSE) assert_that(recursive == FALSE)
if (force == FALSE) assertthat::assert_that(recursive == FALSE)

# Extract json
json <- attr(.x, "JSON")

assert_that(length(json) == nrow(.x))
assertthat::assert_that(length(json) == nrow(.x))

# if json is empty, return empty
if (length(json) == 0) {
Expand All @@ -78,7 +78,7 @@ append_values_factory <- function(type, as.value) {
new_val[loc] <- NA
}
new_val <- new_val %>% as.value
assert_that(length(new_val) == nrow(.x))
assertthat::assert_that(length(new_val) == nrow(.x))
.x[column.name] <- new_val
}

Expand All @@ -92,7 +92,7 @@ append_values_factory <- function(type, as.value) {
#' @param l a list that we want to unlist
#' @param recursive logical indicating whether to unlist nested lists
my_unlist <- function(l, recursive = FALSE) {
nulls <- map_int(l, length) != 1
nulls <- purrr::map_int(l, length) != 1
l[nulls] <- NA
unlist(l, recursive = recursive)
}
Expand Down
4 changes: 2 additions & 2 deletions R/enter_object.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#'
#' @seealso \code{\link{gather_object}} to find sub-objects that could be
#' entered into, \code{\link{gather_array}} to gather an array in an object
#' and \code{\link{spread_all}} to spread values in an object.
#' and \code{\link{spread_all}} or \code{\link{spread_values}} to spread values in an object.
#' @param .x a json string or tbl_json object
#' @param ... a quoted or unquoted sequence of strings designating the object
#' name or sequences of names you wish to enter
Expand Down Expand Up @@ -71,7 +71,7 @@ enter_object <- function(.x, ...) {
json <- attr(.x, "JSON")

# Access path
json <- map(json, path %>% as.list)
json <- purrr::map(json, path %>% as.list)

tbl_json(.x, json, drop.null.json = TRUE)

Expand Down
18 changes: 9 additions & 9 deletions R/gather.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ gather_factory <- function(default.column.name, default.column.empty,

function(.x, column.name = default.column.name) {

assert_that(!("..name" %in% names(.x)))
assert_that(!("..json" %in% names(.x)))
assertthat::assert_that(!("..name" %in% names(.x)))
assertthat::assert_that(!("..json" %in% names(.x)))

if (!is.tbl_json(.x)) .x <- as.tbl_json(.x)

Expand All @@ -36,13 +36,13 @@ gather_factory <- function(default.column.name, default.column.empty,
stop(sprintf("%s records are not %ss", sum(bad_type), required.type))

y <- .x %>%
tbl_df %>%
mutate(
..name = json %>% map(expand.fun),
dplyr::as_tibble() %>%
dplyr::mutate(
..name = json %>% purrr::map(expand.fun),
..json = json %>%
map(~data_frame(..json = as.list(.)))
purrr::map(~dplyr::data_frame(..json = as.list(.)))
) %>%
unnest(..name, ..json, .drop = FALSE)
tidyr::unnest(..name, ..json, .drop = FALSE)

# Check to see if column.name exists, otherwise, increment until not
if (column.name %in% names(y)) {
Expand All @@ -58,10 +58,10 @@ gather_factory <- function(default.column.name, default.column.empty,
}

# Rename
y <- y %>% rename_(.dots = setNames("..name", column.name))
y <- y %>% dplyr::rename_(.dots = setNames("..name", column.name))

# Construct tbl_json
tbl_json(y %>% select(-..json), y$..json)
tbl_json(y %>% dplyr::select(-..json), y$..json)

}

Expand Down
6 changes: 3 additions & 3 deletions R/is_json.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ NULL

#' @rdname is_json
#' @export
is_json_string <- is_json_factory("string")
is_json_string <- is_json_factory('string')

#' @rdname is_json
#' @export
is_json_number <- is_json_factory("number")
is_json_number <- is_json_factory('number')

#' @rdname is_json
#' @export
is_json_logical <- is_json_factory("logical")
is_json_logical <- is_json_factory('logical')

#' @rdname is_json
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/json_complexity.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ json_complexity <- function(.x, column.name = "complexity") {
json <- attr(.x, "JSON")

# Determine lengths
lengths <- json %>% map(unlist, recursive = TRUE) %>% map_int(length)
lengths <- json %>% purrr::map(unlist, recursive = TRUE) %>% purrr::map_int(length)

# Add as a column to x
.x[column.name] <- lengths
Expand Down
2 changes: 1 addition & 1 deletion R/json_lengths.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ json_lengths <- function(.x, column.name = "length") {
json <- attr(.x, "JSON")

# Determine lengths
lengths <- map_int(json, length)
lengths <- purrr::map_int(json, length)

# Add as a column to x
.x[column.name] <- lengths
Expand Down
Loading