Skip to content

Commit f5f0cf6

Browse files
committed
fix rosetta indexing
closes #1110
1 parent 277167c commit f5f0cf6

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

rstan/rstan/R/lookup.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,16 @@ lookup <- function(FUN, ReturnType = character()) {
2727
if(is.function(FUN)) FUN <- deparse(substitute(FUN))
2828
if(!is.character(FUN)) stop("'FUN' must be a character string for a function")
2929
if(length(FUN) != 1) stop("'FUN' must be of length one")
30-
30+
3131
if(FUN == "nrow") FUN <- "NROW"
3232
if(FUN == "ncol") FUN <- "NCOL"
33+
34+
keep_cols <- !(colnames(rosetta) == "RFunction")
3335
if(exists(FUN)) {
3436
matches <- as.logical(charmatch(rosetta$RFunction, FUN, nomatch = 0L))
35-
if(any(matches)) return(rosetta[matches,-1,drop=FALSE])
37+
if(any(matches)) return(rosetta[matches, keep_cols, drop = FALSE])
3638
}
3739
matches <- grepl(FUN, rosetta$StanFunction, ignore.case = TRUE)
38-
if(any(matches)) return(rosetta[matches,-1,drop=FALSE])
40+
if(any(matches)) return(rosetta[matches, keep_cols, drop = FALSE])
3941
else return("no matching Stan functions")
4042
}

0 commit comments

Comments
 (0)