Skip to content

Commit c44402a

Browse files
authored
Merge pull request #1113 from stan-dev/fix-rosetta-indexing-in-lookup
fix rosetta indexing in lookup()
2 parents 277167c + 8d84771 commit c44402a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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)