File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,11 @@ add_boxed <- function(x) {
120
120
d <- x $ data [[i ]]
121
121
idx <- names(d ) %in% get_boxed(d $ type %|| % " scatter" ) & sapply(d , length ) == 1
122
122
if (any(idx )) x $ data [[i ]][idx ] <- lapply(d [idx ], I )
123
+ # (safely) mark individual nested properties
124
+ d $ error_x $ array <- i(d $ error_x $ array )
125
+ d $ error_y $ array <- i(d $ error_y $ array )
126
+ d $ error_x $ arrayminus <- i(d $ error_x $ arrayminus )
127
+ d $ error_y $ arrayminus <- i(d $ error_y $ arrayminus )
123
128
}
124
129
x
125
130
}
@@ -147,6 +152,23 @@ boxers <- list(
147
152
surface = c(" x" , " y" , " z" , " text" )
148
153
)
149
154
155
+ i <- function (x ) if (is.null(x )) x else I(x )
156
+
157
+ # ' Pick an element from a nested list
158
+ # ' @param x a list
159
+ # ' @param nms a character vector specifying a search path
160
+ # ' @example
161
+ # ' x <- list(a = list(b = list(c = "Come and get it!")))
162
+ # ' pick(x, c("a", "b", "c"))
163
+ # ' #> [1] "Come and get it!"
164
+ pick <- function (x , nms ) {
165
+ for (i in seq_along(nms )) {
166
+ nm <- nms [i ]
167
+ x <- x [[nm ]]
168
+ }
169
+ x
170
+ }
171
+
150
172
151
173
rm_asis <- function (x ) {
152
174
# jsonlite converts NULL to {} and NA to null (plotly prefers null to {})
You can’t perform that action at this time.
0 commit comments