Skip to content

Commit

Permalink
Don't munge metadata column names
Browse files Browse the repository at this point in the history
* otherwise they would be made valid (unquoted) R variable names
  • Loading branch information
jefferis committed May 21, 2022
1 parent 2163e27 commit 244b5bf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,14 @@ neuprint_error_check <- function(req) {
#' @param stringsAsFactors Whether to return character vector columns as
#' factors. Note that the default of \code{FALSE} differs from
#' \code{\link{data.frame}} and friends.
#' @param check.names Whether to convert column names into R friendly form. This
#' is not necessary but would be the default for \code{\link{data.frame}} were
#' we not to set it ourselves. See \code{\link{as.data.frame}} for details.
#' @param ... Additional arguments passed to \code{\link{as.data.frame}}
#'
#' @export
neuprint_list2df <- function(x, cols=NULL, return_empty_df=FALSE,
check.names=FALSE,
stringsAsFactors=FALSE, ...) {

if(length(x)>=2 && all(c("columns", "data") %in% names(x))) {
Expand All @@ -87,7 +92,7 @@ neuprint_list2df <- function(x, cols=NULL, return_empty_df=FALSE,

if(!length(x)) {
return(if(return_empty_df){
as.data.frame(structure(replicate(length(cols), logical(0)), .Names=cols))
as.data.frame(structure(replicate(length(cols), logical(0)), .Names=cols), check.names=check.names)
} else NULL)
}

Expand All @@ -108,7 +113,7 @@ neuprint_list2df <- function(x, cols=NULL, return_empty_df=FALSE,
}
l[[cols[i]]]=raw_col
}
as.data.frame(l, stringsAsFactors=stringsAsFactors, ...)
as.data.frame(l, stringsAsFactors=stringsAsFactors, check.names=check.names, ...)
}

#' @importFrom memoise memoise
Expand Down
5 changes: 5 additions & 0 deletions man/neuprint_list2df.Rd

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

0 comments on commit 244b5bf

Please sign in to comment.