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

Commit

Permalink
Allow c(1,5:9) type syntax in formula
Browse files Browse the repository at this point in the history
Also fixed a bug in .gsub for as.factor and factor, which may lead to
infinite loop.
  • Loading branch information
Qian, Hai committed Apr 18, 2014
1 parent d170a70 commit e5b919c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 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.35
Version: 0.1.15.36
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
8 changes: 5 additions & 3 deletions R/utility-generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ arraydb.to.arrayr <- function (str, type = "double", n = 1)
fstr <- f.str[1]
fstr <- .gsub("as\\.factor\\((((?!as\\.factor).)*)\\)", "factor(\\1)",
fstr, perl = T)
fstr <- .gsub("factor\\((((?!as\\.factor).)*)\\)", "as.factor(\\1)",
fstr <- .gsub("([^\\.]|^)factor\\((((?!as\\.factor).)*)\\)", "\\1as.factor(\\2)",
fstr, perl = T)

f2 <- f.str[2] # grouping columns, might be NA
Expand Down Expand Up @@ -432,11 +432,13 @@ arraydb.to.arrayr <- function (str, type = "double", n = 1)
}
}

## ----------------------------------------------------------------------

.replace.colon <- function(s)
{
r <- .gsub("\\[(\\d+):(\\d+)\\]", "[\\1@\\2]", s)
r <- .gsub("(\\d+)\\s*:\\s*(\\d+)", "\\1@\\2", s)
r <- gsub(":", "*", r, perl = T)
r <- .gsub("\\[(\\d+)@(\\d+)\\]", "[\\1:\\2]", r)
r <- .gsub("(\\d+)@(\\d+)", "\\1:\\2", r)
r
}

Expand Down

0 comments on commit e5b919c

Please sign in to comment.