[Sciviews-commits] r490 - komodo/SciViews-K Unit komodo/SciViews-K Unit/.komodotools pkg/SciViews pkg/SciViews/R pkg/SciViews/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 13 16:39:40 CET 2012


Author: phgrosjean
Date: 2012-12-13 16:39:40 +0100 (Thu, 13 Dec 2012)
New Revision: 490

Modified:
   komodo/SciViews-K Unit/.komodotools/.migrated
   komodo/SciViews-K Unit/SciViews-K Unit.komodoproject
   pkg/SciViews/NAMESPACE
   pkg/SciViews/R/character.R
   pkg/SciViews/R/misc.R
   pkg/SciViews/man/character.Rd
Log:
More work in charXXX() functions in SciViews

Modified: komodo/SciViews-K Unit/.komodotools/.migrated
===================================================================
--- komodo/SciViews-K Unit/.komodotools/.migrated	2012-12-11 22:53:37 UTC (rev 489)
+++ komodo/SciViews-K Unit/.komodotools/.migrated	2012-12-13 15:39:40 UTC (rev 490)
@@ -1 +1 @@
-migrated SciViews-K Unit on Tue Oct  5 05:13:54 2010
+migrated SciViews-K Unit on Thu Dec 13 13:46:36 2012

Modified: komodo/SciViews-K Unit/SciViews-K Unit.komodoproject
===================================================================
--- komodo/SciViews-K Unit/SciViews-K Unit.komodoproject	2012-12-11 22:53:37 UTC (rev 489)
+++ komodo/SciViews-K Unit/SciViews-K Unit.komodoproject	2012-12-13 15:39:40 UTC (rev 490)
@@ -7,7 +7,7 @@
 </file>
 <preference-set idref="5434d89d-0d44-ff4a-a625-44da4954f8fc">
   <boolean id="configured">1</boolean>
-  <string id="import_exclude_matches">*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;*%*;tmp*.html;.DS_Store;_prj_internal_</string>
+  <string id="import_exclude_matches">*.*~;*.bak;*.tmp;CVS;.#*;*.pyo;*.pyc;.svn;*%25*;tmp*.html;.DS_Store;_prj_internal_</string>
   <string id="import_include_matches"></string>
   <boolean id="import_live">1</boolean>
   <boolean id="import_recursive">1</boolean>

Modified: pkg/SciViews/NAMESPACE
===================================================================
--- pkg/SciViews/NAMESPACE	2012-12-11 22:53:37 UTC (rev 489)
+++ pkg/SciViews/NAMESPACE	2012-12-13 15:39:40 UTC (rev 490)
@@ -1,30 +1,33 @@
 import(methods, grDevices, graphics, stats, MASS, ellipse, data.table)
 
 export(.Intern,
-	   cAbbreviate,
-	   cEscape,
-	   cExpand,
-	   cFind,
-	   cFindAll,
-	   cFold,
-	   cHeight,
-	   cLower,
-	   cMatch,
-	   cPMatch,
-	   cSearch,
-	   cSplit,
-	   cSubstr,
-	   "cSubstr<-",
-	   cSub,
-	   cSubAll,
-	   cTrans,
-	   cTrim,
-	   cTrimL,
-	   cTrimR,
-	   cTrunc,
-	   cUpper,
-	   cWidth,
-	   cWrap,
+	   char,
+	   as.char,
+	   is.char,
+	   charAbbrev,
+	   charEscape,
+	   charExpand,
+	   charFind,
+	   charFindAll,
+	   charFold,
+	   charHeight,
+	   charLower,
+	   charMatch,
+	   charPMatch,
+	   charSearch,
+	   charSplit,
+	   charSubstr,
+	   "charSubstr<-",
+	   charSub,
+	   charSubAll,
+	   charTrans,
+	   charTrim,
+	   charTrimL,
+	   charTrimR,
+	   charTrunc,
+	   charUpper,
+	   charWidth,
+	   charWrap,
 	   p,
 	   p_,
 	   ct,
@@ -37,6 +40,9 @@
 	   "encoding<-",
 	   setEncoding,
 	   as.integerBase,
+	   as.intBase,
+	   as.char,
+	   is.char,
 	   rx,
 	   perl,
 	   is.rx,
@@ -79,10 +85,6 @@
 	   wdir,
 	   ifElse,
 	   names,
-	   num,
-	   int,
-	   char,
-           logic,
 	   l,
 	   nc,
 	   nr,
@@ -108,8 +110,6 @@
 	   package,
 	   enum,
 	   timing,
-	   
-	   
 	   sysFunction,
 	   sysCall,
 	   matchCall,
@@ -131,10 +131,10 @@
 	   autoloadEnv,
 	   tempEnv,
 	   topEnv,
-	   environmentNew,
-	   environmentParent,
-	   "environmentParent<-",
-	   environmentProfile,
+	   envNew,
+	   envParent,
+	   "envParent<-",
+	   envProfile,
 	   sysSource,
 	   evalQuote,
 	   evalParent,

Modified: pkg/SciViews/R/character.R
===================================================================
--- pkg/SciViews/R/character.R	2012-12-11 22:53:37 UTC (rev 489)
+++ pkg/SciViews/R/character.R	2012-12-13 15:39:40 UTC (rev 490)
@@ -10,9 +10,9 @@
 #nzChar <- nzchar
 
 ## Format character strings
-cEscape <- .Recode(base::encodeString)
-cWrap <- base::strwrap
-# Add cPad => pad a string left/right or both or chrPad/chrPadL/chrPadR?
+charEscape <- .Recode(base::encodeString)
+charWrap <- base::strwrap
+# Add charPad => pad a string left/right or both or charPad/charPadL/charPadR?
 #+sprintf/gettextf?
 
 ## String find/replace using fixed pattern or regular expressions
@@ -69,7 +69,7 @@
 	x
 }
 
-cSearch <- function (x, pattern, ignore.case = FALSE,
+charSearch <- function (x, pattern, ignore.case = FALSE,
 type = c("logical", "position", "value"), max.distance = 0, costs = NULL)
 {
 	type <- pmatch(type)
@@ -119,30 +119,30 @@
 
 ## Inconsistencies: regexpr(pattern, text, ...) and strsplit(x, xplit, ...)
 ## Solved with the present versions!
-cFind <- function (x, pattern, ignore.case = FALSE)
+charFind <- function (x, pattern, ignore.case = FALSE)
 	regexpr(pattern, text = x, ignore.case = ignore.case, fixed = !is.rx(pattern),
 		perl = is.perl(pattern), useBytes = useBytes(pattern))
 	
-cFindAll <- function (x, pattern, ignore.case = FALSE)
+charFindAll <- function (x, pattern, ignore.case = FALSE)
 	gregexpr(pattern, text = x, ignore.case = ignore.case, fixed = !is.rx(pattern),
 		perl = is.perl(pattern), useBytes = useBytes(pattern))
 
-cSub <- function (x, pattern, replacement, ignore.case = FALSE)
+charSub <- function (x, pattern, replacement, ignore.case = FALSE)
 	sub(pattern, replacement, x, ignore.case = ignore.case, fixed = !is.rx(pattern),
 		perl = is.perl(pattern), useBytes = useBytes(pattern))
 	
-cSubAll <- function (x, pattern, replacement, ignore.case = FALSE)
+charSubAll <- function (x, pattern, replacement, ignore.case = FALSE)
 	gsub(pattern, replacement, x, ignore.case = ignore.case, fixed = !is.rx(pattern),
 		perl = is.perl(pattern), useBytes = useBytes(x))
 
 ## Substrings
-cSplit <- function (x, pattern)
+charSplit <- function (x, pattern)
 	strsplit(x, split = pattern, fixed = !is.rx(pattern),
 		perl = is.perl(pattern), useBytes = useBytes(pattern))
 
-cSubstr <- .Recode(base::substr)
-`cSubstr<-` <- .Recode(base::`substr<-`)
-cTrunc <- .Recode(base::strtrim) ## This indeed truncs strings!!!
+charSubstr <- .Recode(base::substr)
+`charSubstr<-` <- .Recode(base::`substr<-`)
+charTrunc <- .Recode(base::strtrim) ## This indeed truncs strings!!!
 
 ## paste() is rather long name, in comparison with, e.g., c().
 ## Also the default argument of sep = " " is irritating and is not consistent
@@ -182,27 +182,27 @@
 		append = TRUE)
 
 	
-cTrim <- function (x, all.spaces = FALSE) # Trim both sides
+charTrim <- function (x, all.spaces = FALSE) # Trim both sides
 {
 	pat <- (if (isTRUE(all.spaces)) "[[:space:]]+" else "[[:blank:]]+")
 	## Trim left first
-	x <- cSub(p("^", pat), "", x)
+	x <- charSub(p("^", pat), "", x)
 	## ... then trim right
-	cSub(p(pat, "$"), "", x)
+	charSub(p(pat, "$"), "", x)
 }
 
-cTrimL <- function (x, all.spaces = FALSE) # Trim left-side only
-	cSub(if (isTRUE(all.spaces)) "^[[:space:]]+" else "^[[:blank:]]+", "", x)
+charTrimL <- function (x, all.spaces = FALSE) # Trim left-side only
+	charSub(if (isTRUE(all.spaces)) "^[[:space:]]+" else "^[[:blank:]]+", "", x)
 
-cTrimR <- function (x, all.spaces = FALSE) # Trim right-side only
-	cSub(if (isTRUE(all.spaces)) "[[:space:]]+$" else "[[:blank:]]+$", "", x)
+charTrimR <- function (x, all.spaces = FALSE) # Trim right-side only
+	charSub(if (isTRUE(all.spaces)) "[[:space:]]+$" else "[[:blank:]]+$", "", x)
 
 
 ## Change case and translate
-cTrans <- function (x, old, new) chartr(old = old, new = new, x = x)
-cFold <- base::casefold
-cLower <- .Recode(base::tolower)
-cUpper <- .Recode(base::toupper)
+charTrans <- function (x, old, new) chartr(old = old, new = new, x = x)
+charFold <- base::casefold
+charLower <- .Recode(base::tolower)
+charUpper <- .Recode(base::toupper)
 
 ## Character encoding
 encodingToNative <- base::enc2native
@@ -212,28 +212,29 @@
 `encoding<-` <- setEncoding <- .Recode(base::`Encoding<-`)
 
 ## Measure size of a string (package graphics)
-cHeight <- .Recode(graphics::strheight)
-cWidth <- .Recode(graphics::strwidth)
+charHeight <- .Recode(graphics::strheight)
+charWidth <- .Recode(graphics::strwidth)
 
 ## Match, expand or abbreviate character strings to a list of items
-cAbbreviate <- function (x, min.length = 4, dot = FALSE, strict = FALSE,
+charAbbrev <- function (x, min.length = 4, dot = FALSE, strict = FALSE,
 method = c("left.kept", "both.sides"))
 	abbreviate(names.arg = x, minlength = min.length, dot = dot, strict = strict,
 		method = method)
 
-cExpand <- function (x, target, nomatch = NA_character_)
+charExpand <- function (x, target, nomatch = NA_character_)
 	char.expand(input = x, target = target, nomatch = nomatch)
 
-cMatch <- .Recode(base::charmatch)
-cPMatch <- .Recode(base::pmatch)
+charMatch <- .Recode(base::charmatch)
+charPMatch <- .Recode(base::pmatch)
 
-## Conversion to character string... no change required
-#as.character
+## Conversion to character string... + creation and test, shorter versions
+char <- .Recode(base::character)
+as.char <- base::as.character
+is.char <- base::is.character
 
 # To avoid using strtoi(), we prefer as.integerBase (because as.integer cannot
 # be converted into a generic function, because it is a primitive!)
-#charToInt <- strtoi # Allows to choose the base used for char representation
-as.integerBase <- .Recode(base::strtoi)
+as.intBase <- as.integerBase <- .Recode(base::strtoi)
 
 ## Define a function that takes: singular/plural msg and a vector of strings
 ## and construct a single string with:
@@ -241,5 +242,3 @@
 ## or
 ## plural msg: item1, item2, ..., itemN
 #+paste = cChar? + my special character string manipulation functions?
-
-

Modified: pkg/SciViews/R/misc.R
===================================================================
--- pkg/SciViews/R/misc.R	2012-12-11 22:53:37 UTC (rev 489)
+++ pkg/SciViews/R/misc.R	2012-12-13 15:39:40 UTC (rev 490)
@@ -105,10 +105,10 @@
 ## Do we implement `names<-` for environments??? This is a nonsense, may be?
 
 ## Simpler names for often used functions
-num <- base::as.numeric
-int <- base::as.integer
-char <- base::as.character
-logic <- base::as.logical
+#as.num <- base::as.numeric
+#as.int <- base::as.integer
+#as.logic <- base::as.logical
+# is.num, is.int, is.logic + num, int and logic
 ## To avoid problems with factors, tell to always use s(f1), or n(f1)/i(f1)
 
 ## Since n is already used for a synonym of as.numeric(), I use l() here
@@ -476,15 +476,15 @@
 # Usually, to create an object, we use its name, but
 ## environment() means something else here!
 ## So, OK, we'll stick with:
-environmentNew <- .Recode(base::new.env)
+envNew <- .Recode(base::new.env)
 ## Should not be used!
-environmentParent <- .Recode(base::parent.env)
-`environmentParent<-` <- .Recode(base::`parent.env<-`)
+envParent <- .Recode(base::parent.env)
+`envParent<-` <- .Recode(base::`parent.env<-`)
 #environmentName()
 #environment()
 #`environment<-`()
 #is.environment()
-environmentProfile <- .Recode(base::env.profile)
+envProfile <- .Recode(base::env.profile)
 ## name attribute to an environment,... see ?environment
 #source()
 

Modified: pkg/SciViews/man/character.Rd
===================================================================
--- pkg/SciViews/man/character.Rd	2012-12-11 22:53:37 UTC (rev 489)
+++ pkg/SciViews/man/character.Rd	2012-12-13 15:39:40 UTC (rev 490)
@@ -1,34 +1,37 @@
-\name{character-fun}
+\name{char-fun}
+\alias{char}
+\alias{as.char}
+\alias{is.char}
 \alias{ct}
 \alias{cta}
 \alias{ct_}
 \alias{cta_}
 \alias{p}
 \alias{p_}
-\alias{cTrans}
-\alias{cFold}
-\alias{cLower}
-\alias{cUpper}
-\alias{cSplit}
-\alias{cTrim}
-\alias{cTrimL}
-\alias{cTrimR}
-\alias{cTrunc}
-\alias{cSubstr} 
-\alias{cSubstr<-}
-\alias{cSearch}
-\alias{cFind}
-\alias{cFindAll}
-\alias{cSub}
-\alias{cSubAll}
-\alias{cMatch}
-\alias{cPMatch}
-\alias{cExpand}
-\alias{cAbbreviate}
-\alias{cEscape}
-\alias{cWrap}
-\alias{cHeight}
-\alias{cWidth}
+\alias{charTrans}
+\alias{charFold}
+\alias{charLower}
+\alias{charUpper}
+\alias{charSplit}
+\alias{charTrim}
+\alias{charTrimL}
+\alias{charTrimR}
+\alias{charTrunc}
+\alias{charSubstr} 
+\alias{charSubstr<-}
+\alias{charSearch}
+\alias{charFind}
+\alias{charFindAll}
+\alias{charSub}
+\alias{charSubAll}
+\alias{charMatch}
+\alias{charPMatch}
+\alias{charExpand}
+\alias{charAbbrev}
+\alias{charEscape}
+\alias{charWrap}
+\alias{charHeight}
+\alias{charWidth}
 
 \title{Character strings manipulation functions}
 
@@ -37,6 +40,11 @@
 }
 
 \usage{
+## Create, test or coerce to character
+char(length = 0)
+as.char(x, \dots)
+is.char(x)
+
 ## Concatenate and print strings to the console or in a file
 ct(\dots, file = "", end = "\n", fill = FALSE, labels = NULL)
 cta(\dots, file = "", end = "\n", fill = FALSE, labels = NULL)
@@ -48,49 +56,53 @@
 p_(\dots, sep = " ", collapse = NULL)
 
 ## character translation or folding
-cTrans(x, old, new)
-cFold(x, upper = FALSE)
-cLower(x)
-cUpper(x)
+charTrans(x, old, new)
+charFold(x, upper = FALSE)
+charLower(x)
+charUpper(x)
 
 ## Split, truncate or work with substrings
-cTrim(x, all.spaces = FALSE)
-cTrimL(x, all.spaces = FALSE)
-cTrimR(x, all.spaces = FALSE)
-cTrunc(x, width)
-cSubstr(x, start, stop) 
-cSubstr(x, start, stop) <- value
-cSplit(x, pattern)
+charTrim(x, all.spaces = FALSE)
+charTrimL(x, all.spaces = FALSE)
+charTrimR(x, all.spaces = FALSE)
+charTrunc(x, width)
+charSubstr(x, start, stop) 
+charSubstr(x, start, stop) <- value
+charSplit(x, pattern)
 
 ## Find and replace in character strings
-cSub(x, pattern, replacement, ignore.case = FALSE)
-cSubAll(x, pattern, replacement, ignore.case = FALSE)
-cFind(x, pattern, ignore.case = FALSE)
-cFindAll(x, pattern, ignore.case = FALSE)
-cSearch(x, pattern, ignore.case = FALSE,
+charSub(x, pattern, replacement, ignore.case = FALSE)
+charSubAll(x, pattern, replacement, ignore.case = FALSE)
+charFind(x, pattern, ignore.case = FALSE)
+charFindAll(x, pattern, ignore.case = FALSE)
+charSearch(x, pattern, ignore.case = FALSE,
     type = c("logical", "position", "value"), max.distance = 0, costs = NULL)
 
 ## Match, expand or abbreviate character strings
-cMatch(x, table, nomatch = NA_integer_) 
-cPMatch(x, table, nomatch = NA_integer_, duplicates.ok = FALSE)
-cExpand(x, target, nomatch = NA_character_)
-cAbbreviate(x, min.length = 4, dot = FALSE, strict = FALSE,
+charMatch(x, table, nomatch = NA_integer_) 
+charPMatch(x, table, nomatch = NA_integer_, duplicates.ok = FALSE)
+charExpand(x, target, nomatch = NA_character_)
+charAbbrev(x, min.length = 4, dot = FALSE, strict = FALSE,
     method = c("left.kept", "both.sides"))
 
 ## Format character strings
-cEscape(x, width = 0L, quote = "", na.encode = TRUE,
+charEscape(x, width = 0L, quote = "", na.encode = TRUE,
     justify = c("left", "right", "centre", "none")) 
-cWrap(x, width = 0.9 * getOption("width"), indent = 0, exdent = 0, 
+charWrap(x, width = 0.9 * getOption("width"), indent = 0, exdent = 0, 
     prefix = "", simplify = TRUE, initial = prefix)
 
-## Measure size of a character string or expression in a graph
-cHeight(s, units = "user", cex = NULL, font = NULL, vfont = NULL, \dots)
-cWidth(s, units = "user", cex = NULL, font = NULL, vfont = NULL, \dots)
+## Measure size of a character string or expression in a plot
+charHeight(s, units = "user", cex = NULL, font = NULL, vfont = NULL, \dots)
+charWidth(s, units = "user", cex = NULL, font = NULL, vfont = NULL, \dots)
 }
 
 \arguments{
+  \item{length}{ the length of the character vector to create. }
+  \item{x}{ a character string or an object that can be coerced to character or
+    tested as such. }
   \item{\dots}{ a series of character strings or objects that can be coerced to
-    character. }
+    character, or further arguments passed to or from other methods for
+    \code{as.char()}. }
   \item{file}{ a character string naming a file, or a connection. The default
     \code{""} prints to the standard output connection (see \code{\link[base]{cat}}). }
   \item{end}{ the character string to append at the end. By default, a carriage
@@ -103,7 +115,6 @@
   \item{sep}{ the character string to use to separate successive strings. }
   \item{collapse}{ an optional character string to separate items in a character
     vector that is collapsed to a single item. }
-  \item{x}{ a character string or an object that can be coerced to character. }
   \item{old}{ a character string with characters to be translated. First element
     is used with a warning if length is higher than two. }
   \item{new}{ a character string with the translations. First element
@@ -144,11 +155,11 @@
 }
 
 \details{
-  All these functions start with a lowercase c before an uppercase letter to
-  indicate that they operate on, character strings and coerce their first
+  All these functions start with char before an uppercase letter to
+  indicate that they operate on character strings or coerce their first
   argument \code{x} to a character object.
   
-  \code{cEscape(x)} ...
+  \code{charEscape(x)} ...
 }
 
 \value{



More information about the Sciviews-commits mailing list