Type: | Package |
Title: | 'htmlwidget' for Interactive Views of R Lists |
Version: | 4.0.0 |
Date: | 2023-09-30 |
Description: | R lists, especially nested lists, can be very difficult to visualize or represent. Sometimes 'str()' is not enough, so this suite of htmlwidgets is designed to help see, understand, and maybe even modify your R lists. The function 'reactjson()' requires a package 'reactR' that can be installed from CRAN or https://github.com/timelyportfolio/reactR. |
License: | MIT + file LICENSE |
URL: | https://github.com/timelyportfolio/listviewer |
BugReports: | https://github.com/timelyportfolio/listviewer/issues |
Imports: | htmltools, htmlwidgets, shiny |
Suggests: | jsonlite, miniUI, rstudioapi |
Enhances: | reactR |
RoxygenNote: | 7.2.3 |
NeedsCompilation: | no |
Packaged: | 2023-09-30 19:00:08 UTC; kentr |
Author: | Jos de Jong [aut, cph] (jsoneditor.js library in htmlwidgets/jsoneditor, http://github.com/josdejong/jsoneditor/), Mac Gainer [aut, cph] (react-json-view library in htmlwidgets/react-json, https://github.com/mac-s-g/react-json-view), Kent Russell [aut, cre] (R interface) |
Maintainer: | Kent Russell <kent.russell@timelyportfolio.com> |
Repository: | CRAN |
Date/Publication: | 2023-09-30 19:30:06 UTC |
View Lists
with 'jsoneditor'
Description
jsonedit
provides a flexible and helpful interactive tree-like view of lists
or really any R dataset that can be represented as JSON
.
Eventually, this could become a very nice way to not only view but also modify R data using
Shiny.
Usage
jsonedit(
listdata = NULL,
mode = "tree",
modes = c("text", "tree", "table"),
...,
width = NULL,
height = NULL,
elementId = NULL
)
Arguments
listdata |
|
mode |
|
modes |
|
... |
|
width |
integer in pixels defining the width of the |
height |
integer in pixels defining the height of the |
elementId |
character to specify valid |
Examples
library(listviewer)
# using the data from the jsoneditor simple example
# in R list form
jsonedit(
list(
array = c(1,2,3)
,boolean = TRUE
,null = NULL
,number = 123
,object = list( a="b", c="d" )
,string = "Hello World"
)
)
# jsonedit also works with a JSON string
jsonedit(
'{"array" : [1,2,3] , "boolean" : true, "null" : null, "number": 123}'
)
# also works with most data.frames
jsonedit( mtcars )
# helpful interactive view of par
jsonedit( par() )
Shiny Bindings for 'jsonedit'
Description
Output and render functions for using jsonedit within Shiny applications and interactive Rmd documents.
Usage
jsoneditOutput(outputId, width = "100%", height = "400px")
renderJsonedit(expr, env = parent.frame(), quoted = FALSE)
Arguments
outputId |
output variable to read from |
width , height |
Must be a valid CSS unit (like |
expr |
An expression that generates a jsonedit |
env |
The environment in which to evaluate |
quoted |
Is |
jsoneditAddin
Description
This uses the gadget as an addin, so you can select objects then activate the addin in RStudio either via menu or a hotkey.
Usage
jsoneditAddin()
Shiny Gadget for 'jsonedit'
Description
Provides a Shiny gadget
interface for jsonedit
to interactively edit and return the
changes for use in R.
Usage
jsonedit_gadget(..., height = NULL, width = NULL)
Arguments
... |
arguments for |
height , width |
any valid |
Examples
## Not run:
library(listviewer)
jsonedit_gadget(
structure(
as.list(1:4),
names=letters[1:4]
)
)
## End(Not run)
listviewer.
Description
htmlwidget for interactive views of R lists
Details
R lists, especially nested lists, can be very difficult to visualize or
represent. str
just isn't enough, so this suite of htmlwidgets is
designed to help see, understand, and maybe even modify your R lists.
Number Starting at 1
Description
JavaScript starts at 0
, but R starts at 1
.
This means unnamed lists and vectors are indexed starting at
0
in listviewer widgets. This little helper function
tries to resolve the disconnect by assigning sequential numbers
starting at 1
to names for unnamed lists
and vectors
.
Please note though that using number_unnamed
will potentially
cause difficulties serializing back and forth between JavaScript and R.
Usage
number_unnamed(l)
Arguments
l |
|
Examples
library(listviewer)
jsonedit(
number_unnamed(list(x=list(letters[1:3])))
)
Edit R Data with 'react-json'
Description
Edit R Data with 'react-json'
Usage
reactjson(
listdata = list(),
name = "root",
theme = "rjv-default",
iconStyle = c("circle", "triangle", "square"),
indentWidth = 4,
collapsed = FALSE,
collapseStringsAfterLength = FALSE,
groupArraysAfterLength = 100,
enableClipboard = TRUE,
displayObjectSize = TRUE,
displayDataTypes = TRUE,
onEdit = TRUE,
onAdd = TRUE,
onDelete = TRUE,
onSelect = TRUE,
sortKeys = FALSE,
width = NULL,
height = NULL,
elementId = NULL
)
Arguments
listdata |
|
name |
|
theme |
|
iconStyle |
|
indentWidth |
|
collapsed |
|
collapseStringsAfterLength |
|
groupArraysAfterLength |
|
enableClipboard |
|
displayObjectSize |
|
displayDataTypes |
|
onEdit , onAdd , onDelete , onSelect |
|
sortKeys |
|
width |
integer in pixels defining the width of the |
height |
integer in pixels defining the height of the |
elementId |
character to specify valid |
Examples
## Not run:
library(listviewer)
# use reactR for React dependencies
# devtools::install_github("timelyportfolio/reactR")
library(reactR)
reactjson()
reactjson(head(mtcars,4))
reactjson(I(jsonlite::toJSON(head(mtcars,5))))
library(shiny)
shinyApp(
ui = reactjson(
list(x=1,msg="react+r+shiny",opts=list(use_react=FALSE)),
elementId = "json1"
),
server = function(input, output, session){
observeEvent(
input$json1_change,
str(input$json1_change)
)
}
)
# gadget to use as editor
library(miniUI)
ui <- miniUI::miniPage(
miniUI::miniContentPanel(
reactjson(
list(x=1,msg="react+r+shiny",opts=list(use_react=FALSE)),
elementId = "rjeditor"
)
),
miniUI::gadgetTitleBar(
"Edit",
right = miniUI::miniTitleBarButton("done", "Done", primary = TRUE)
)
)
server <- function(input, output, session) {
shiny::observeEvent(input$done, {
shiny::stopApp(
input$rjeditor_change
)
})
shiny::observeEvent(input$cancel, { shiny::stopApp (NULL) })
}
runGadget(
ui,
server,
viewer = shiny::paneViewer()
)
## End(Not run)
Shiny bindings for reactjson
Description
Output and render functions for using reactjson within Shiny applications and interactive Rmd documents.
Usage
reactjsonOutput(outputId, width = "100%", height = "400px")
renderReactjson(expr, env = parent.frame(), quoted = FALSE)
Arguments
outputId |
output variable to read from |
width , height |
Must be a valid CSS unit (like |
expr |
An expression that generates a reactjson |
env |
The environment in which to evaluate |
quoted |
Is |
Recurse Over Nested Lists
Description
Like rapply
but recurses over nested lists and
retain attributes
and names
.
Usage
recurse(l, func, ...)
Arguments
l |
|
func |
|
... |
arguments for the |