Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
Bug fix: array index cannot be larger than 10 in margins
Browse files Browse the repository at this point in the history
  • Loading branch information
Qian, Hai committed Apr 12, 2014
1 parent 7131001 commit 316fe38
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: PivotalR
Type: Package
Title: R front-end to PostgreSQL and Pivotal (Greenplum) database,
wrapper for MADlib
Version: 0.1.15.21
Version: 0.1.15.22
Date: 2014-03-10
Author: Predictive Analytics Team at Pivotal Inc. <user@madlib.net>,
with contributions from Data Scientist Team at Pivotal Inc.
Expand Down
10 changes: 6 additions & 4 deletions R/margins.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ Vars <- function(model)
## ------- Add quotes -------
mvars <- Vars(model)
model.vars <- .add.quotes(gsub("`", "", model.vars), mvars)

model.vars <- lapply(model.vars, function(x)
eval(parse(text=paste("quote(", x, ")", sep = ""))))

names(model.vars) <- paste("\"term.", seq_len(n), "\"", sep = "")

if (any(! (gsub("\"", "", gsub("`", "", expand.vars)) %in%
Expand All @@ -215,8 +217,10 @@ Vars <- function(model)
"or the table column names!")

expand.vars <- paste("\"", expand.vars, "\"", sep = "")
expand.vars <- gsub("\"`\"([^\\[\\]]*)\"\\[([^\\[\\]]*)\\]`\"", "\"\\1\"[\\2]", expand.vars)
expand.vars <- gsub("\"`([^\\[\\]]*)\\[([^\\[\\]]*)\\]`\"", "\"\\1\"[\\2]", expand.vars)
expand.vars <- gsub("\"`\"([^\\[\\]]*)\"\\[([^\\[\\]]*)\\]`\"", "\"\\1\"[\\2]",
expand.vars, perl = TRUE)
expand.vars <- gsub("\"`([^\\[\\]]*)\\[([^\\[\\]]*)\\]`\"", "\"\\1\"[\\2]",
expand.vars, perl = TRUE)

return (list(vars = expand.vars, is.ind = expand.is.ind,
is.factor = is.factor, factors = factors,
Expand Down Expand Up @@ -1020,5 +1024,3 @@ margins.logregr.madlib.grps <- function(model, dydx = ~ Vars(model),
} else
var
}


0 comments on commit 316fe38

Please sign in to comment.