From 1d41984ada6e7c4d89128881a5ef3220ed596519 Mon Sep 17 00:00:00 2001 From: Gregory Jefferis Date: Tue, 29 Sep 2020 09:36:05 +0100 Subject: [PATCH] Fix neuprint_connection_table when 0 connections * closes #135 --- R/connectivity.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/connectivity.R b/R/connectivity.R index 7270429c..3775977a 100644 --- a/R/connectivity.R +++ b/R/connectivity.R @@ -270,7 +270,11 @@ neuprint_connection_table <- function(bodyids, } d <- neuprint_list2df(nc, return_empty_df = TRUE) d$weight <- as.integer(d$weight) - d$prepost <- ifelse(prepost=="PRE",0,1) + if(nrow(d)==0) { + d$prepost=integer(length = 0L) + } else { + d$prepost <- ifelse(prepost=="PRE",0,1) + } if(!is.null(roi)){ d <- d[d$roi%in%roi,] }