File: utils.R

package info (click to toggle)
r-cran-restfulr 0.0.15-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 200 kB
  • sloc: ansic: 67; sh: 13; makefile: 2
file content (21 lines) | stat: -rw-r--r-- 685 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
### =========================================================================
### Low-level utilities
### -------------------------------------------------------------------------

raggedListToDF <- function(x, keepAlwaysNULL = TRUE, ...) {
  nms <- unlist(lapply(x, names))
  uniq.nms <- unique(nms)
  ind <- match(nms, uniq.nms)
  cols <- .Call(R_raggedListToDF, x, uniq.nms, ind)
  nulls <- vapply(cols, is.null, logical(1L))
  if (keepAlwaysNULL) {
      cols[nulls] <- list(rep(NA, length(x)))
  } else {
      cols[nulls] <- NULL
  }
  as.data.frame(cols, ...)
}

setMethod("unstrsplit", "AsIs", function(x, sep = "") {
              unstrsplit(unclass(x), sep=sep)
          })