[Sciviews-commits] r465 - in pkg: SciViews SciViews/R svSweave svSweave/R svSweave/inst svSweave/inst/asciidoc svSweave/inst/asciidoc/filters svSweave/inst/asciidoc/filters/code svSweave/inst/asciidoc/filters/graphviz svSweave/inst/asciidoc/filters/latex svSweave/inst/asciidoc/filters/music svSweave/inst/asciidoc/filters/source svSweave/inst/asciidoc/javascripts svSweave/inst/asciidoc/stylesheets svSweave/inst/asciidoc/themes svSweave/inst/asciidoc/themes/flask svSweave/inst/asciidoc/themes/sciviews svSweave/inst/asciidoc/themes/volnitsky svSweave/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Apr 15 23:37:40 CEST 2012


Author: phgrosjean
Date: 2012-04-15 23:37:40 +0200 (Sun, 15 Apr 2012)
New Revision: 465

Added:
   pkg/SciViews/R/graphics.R
   pkg/svSweave/R/asciidoc.R
   pkg/svSweave/R/svSweave-internal.R
   pkg/svSweave/inst/asciidoc/
   pkg/svSweave/inst/asciidoc/.DS_Store
   pkg/svSweave/inst/asciidoc/BUGS.txt
   pkg/svSweave/inst/asciidoc/CHANGELOG.txt
   pkg/svSweave/inst/asciidoc/COPYING
   pkg/svSweave/inst/asciidoc/COPYRIGHT
   pkg/svSweave/inst/asciidoc/README.txt
   pkg/svSweave/inst/asciidoc/asciidoc.conf
   pkg/svSweave/inst/asciidoc/asciidoc.py
   pkg/svSweave/inst/asciidoc/filters/
   pkg/svSweave/inst/asciidoc/filters/code/
   pkg/svSweave/inst/asciidoc/filters/code/code-filter-readme.txt
   pkg/svSweave/inst/asciidoc/filters/code/code-filter-test.txt
   pkg/svSweave/inst/asciidoc/filters/code/code-filter.conf
   pkg/svSweave/inst/asciidoc/filters/code/code-filter.py
   pkg/svSweave/inst/asciidoc/filters/graphviz/
   pkg/svSweave/inst/asciidoc/filters/graphviz/asciidoc-graphviz-sample.txt
   pkg/svSweave/inst/asciidoc/filters/graphviz/graphviz-filter.conf
   pkg/svSweave/inst/asciidoc/filters/graphviz/graphviz2png.py
   pkg/svSweave/inst/asciidoc/filters/latex/
   pkg/svSweave/inst/asciidoc/filters/latex/latex-filter.conf
   pkg/svSweave/inst/asciidoc/filters/latex/latex2png.py
   pkg/svSweave/inst/asciidoc/filters/music/
   pkg/svSweave/inst/asciidoc/filters/music/music-filter-test.txt
   pkg/svSweave/inst/asciidoc/filters/music/music-filter.conf
   pkg/svSweave/inst/asciidoc/filters/music/music2png.py
   pkg/svSweave/inst/asciidoc/filters/source/
   pkg/svSweave/inst/asciidoc/filters/source/source-highlight-filter-test.txt
   pkg/svSweave/inst/asciidoc/filters/source/source-highlight-filter.conf
   pkg/svSweave/inst/asciidoc/help.conf
   pkg/svSweave/inst/asciidoc/javascripts/
   pkg/svSweave/inst/asciidoc/javascripts/ASCIIMathML.js
   pkg/svSweave/inst/asciidoc/javascripts/LaTeXMathML.js
   pkg/svSweave/inst/asciidoc/javascripts/asciidoc.js
   pkg/svSweave/inst/asciidoc/javascripts/slidy.js
   pkg/svSweave/inst/asciidoc/javascripts/toc.js
   pkg/svSweave/inst/asciidoc/lang-de.conf
   pkg/svSweave/inst/asciidoc/lang-en.conf
   pkg/svSweave/inst/asciidoc/lang-es.conf
   pkg/svSweave/inst/asciidoc/lang-fr.conf
   pkg/svSweave/inst/asciidoc/lang-hu.conf
   pkg/svSweave/inst/asciidoc/lang-it.conf
   pkg/svSweave/inst/asciidoc/lang-nl.conf
   pkg/svSweave/inst/asciidoc/lang-pt-BR.conf
   pkg/svSweave/inst/asciidoc/lang-ru.conf
   pkg/svSweave/inst/asciidoc/lang-uk.conf
   pkg/svSweave/inst/asciidoc/slidy.conf
   pkg/svSweave/inst/asciidoc/stylesheets/
   pkg/svSweave/inst/asciidoc/stylesheets/.DS_Store
   pkg/svSweave/inst/asciidoc/stylesheets/asciidoc.css
   pkg/svSweave/inst/asciidoc/stylesheets/pygments.css
   pkg/svSweave/inst/asciidoc/stylesheets/slidy.css
   pkg/svSweave/inst/asciidoc/stylesheets/toc2.css
   pkg/svSweave/inst/asciidoc/themes/
   pkg/svSweave/inst/asciidoc/themes/flask/
   pkg/svSweave/inst/asciidoc/themes/flask/flask.css
   pkg/svSweave/inst/asciidoc/themes/sciviews/
   pkg/svSweave/inst/asciidoc/themes/sciviews/sciviews.css
   pkg/svSweave/inst/asciidoc/themes/volnitsky/
   pkg/svSweave/inst/asciidoc/themes/volnitsky/volnitsky.css
   pkg/svSweave/inst/asciidoc/xhtml11.conf
   pkg/svSweave/man/asciidoc.Rd
Modified:
   pkg/SciViews/NAMESPACE
   pkg/SciViews/R/character.R
   pkg/SciViews/R/file.R
   pkg/SciViews/R/misc.R
   pkg/svSweave/DESCRIPTION
   pkg/svSweave/NAMESPACE
   pkg/svSweave/NEWS
   pkg/svSweave/R/weaveLyxRnw.R
   pkg/svSweave/man/svSweave-package.Rd
Log:
Asciidoc Sweave documents formating added to svSweave

Modified: pkg/SciViews/NAMESPACE
===================================================================
--- pkg/SciViews/NAMESPACE	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/SciViews/NAMESPACE	2012-04-15 21:37:40 UTC (rev 465)
@@ -10,10 +10,10 @@
 	   cMatch,
 	   cSearch,
 	   cSplit,
+	   cSubstr,
+	   "cSubstr<-",
 	   cSub,
-	   "cSub<-",
-	   cRep,
-	   cRepAll,
+	   cSubAll,
 	   cTrans,
 	   cTrim,
 	   cTrimL,
@@ -38,8 +38,8 @@
 	   rxFindAll,
 	   rxSearch,
 	   rxSplit,
-	   rxRep,
-	   rxRepAll,
+	   rxSub,
+	   rxSubAll,
 	   path,
 	   as.path,
 	   is.path,
@@ -74,26 +74,35 @@
 	   dirTemp,
 	   sdir,
 	   wdir,
-	   valid,
-	   ifValid,
 	   ifElse,
-	   newEnv,
 	   names,
 	   n,
+	   i,
+	   l,
 	   nc,
 	   nr,
 	   Rows,
 	   Cols,
+	   any.,
+	   all.,
+	   one,
+	   one.,
+	   asTRUE,
+	   isFALSE,
+	   asFALSE,
+	   "!",
 	   "@",
 	   "@<-",
 	   "@:=",
 	   ":=",
 	   "%:%",
 	   "%else%",
-	   ".",
+	   isEmpty,
 	   package,
 	   enum,
 	   timing,
+	   opt,
+	   optDef,
 	   correlation,
 	   is.correlation,
 	   as.correlation,
@@ -117,10 +126,12 @@
 	   pcomp,
 	   scores,
 	   vectorplot)
+	   
+S3method(one, default)
 
 S3method(print, path)
 
-S3method(valid, default)
+S3method(print, s)
 
 S3method(vectorplot, default)
 S3method(vectorplot, loadings)

Modified: pkg/SciViews/R/character.R
===================================================================
--- pkg/SciViews/R/character.R	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/SciViews/R/character.R	2012-04-15 21:37:40 UTC (rev 465)
@@ -1,7 +1,8 @@
 ## Essentially a series of base R function that manipulate character strings
 ## and that are renamed/rationalized for facility
+
 ## TODO: deal with zero length strings and NAs appropriately in all functions
-## TODO: make.names, make.unique, Sys.setFileTime => fileTime, Sys.umask
+## TODO: make.names, make.unique, abbreviate
 
 ## Count the number of characters
 ## No: make an exception: after n (or nz) do not use uppercase!
@@ -79,19 +80,19 @@
 	return(gregexpr(pattern, text = x, ignore.case = ignore.case, fixed = FALSE,
 		...))
 
-cRep <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for useBytes
+cSub <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for useBytes
 	return(sub(pattern, replacement, x, ignore.case = ignore.case, fixed = TRUE,
 		...))
 	
-rxRep <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for Perl & useBytes
+rxSub <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for Perl & useBytes
 	return(sub(pattern, replacement, x, ignore.case = ignore.case, fixed = FALSE,
 		...))
 	
-cRepAll <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for useBytes
+cSubAll <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for useBytes
 	return(gsub(pattern, replacement, x, ignore.case = ignore.case, fixed = TRUE,
 		...))
 	
-rxRepAll <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for Perl & useBytes
+rxSubAll <- function (x, pattern, replacement, ignore.case = FALSE, ...) # ... for Perl & useBytes
 	return(gsub(pattern, replacement, x, ignore.case = ignore.case, fixed = FALSE,
 		...))
 
@@ -103,8 +104,8 @@
 rxSplit <- function (x, pattern, ...) # for perl & useBytes
 	return(strsplit(x, split = pattern, fixed = FALSE, ...))
 
-cSub <- get("substr", envir = baseenv())
-`cSub<-` <- get("substr<-", envir = baseenv())
+cSubstr <- get("substr", envir = baseenv())
+`cSubstr<-` <- get("substr<-", envir = baseenv())
 cTrunc <- get("strtrim", envir = baseenv()) ## This indeed truncs strings!!!
 
 ## paste() is rather long name, in comparison with, e.g., c().
@@ -149,21 +150,21 @@
 {
 	pat <- (if (isTRUE(all.spaces)) "[[:space:]]+" else "[[:blank:]]+")
 	## Trim left first
-	x <- cRep(p("^", pat), "", x)
+	x <- cSub(p("^", pat), "", x)
 	## ... then trim right
-	return(cRep(p(pat, "$"), "", x))
+	return(cSub(p(pat, "$"), "", x))
 }
 
 cTrimL <- function (x, all.spaces = FALSE) # Trim left-side only
 {
 	pat <- (if (isTRUE(all.spaces)) "^[[:space:]]+" else "^[[:blank:]]+")
-	return(cRep(pat, "", x))
+	return(cSub(pat, "", x))
 }
 
 cTrimR <- function (x, all.spaces = FALSE) # Trim right-side only
 {
 	pat <- (if (isTRUE(all.spaces)) "[[:space:]]+$" else "[[:blank:]]+$")
-	return(cRep(pat, "", x))
+	return(cSub(pat, "", x))
 }
 
 

Modified: pkg/SciViews/R/file.R
===================================================================
--- pkg/SciViews/R/file.R	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/SciViews/R/file.R	2012-04-15 21:37:40 UTC (rev 465)
@@ -1,5 +1,6 @@
 ## Essentially a series of base R function that manipulate files and directories
 ## and that are renamed/rationalized for facility
+## TODO: Sys.setFileTime => fileTime, Sys.umask
 
 ## A replacement for file.path
 path <- function (..., fsep = .Platform$file.sep)

Added: pkg/SciViews/R/graphics.R
===================================================================
--- pkg/SciViews/R/graphics.R	                        (rev 0)
+++ pkg/SciViews/R/graphics.R	2012-04-15 21:37:40 UTC (rev 465)
@@ -0,0 +1,363 @@
+## Package graphics: renaming of functions to meet SciViews coding convention
+## and definition of a couple new functions
+## Must add things from plotrix!!! => svPlot + vioplot + wvioplot + beanplot + ellipse + gplots
+
+## Graphical options
+## par(.., no.readonly = FALSE) is not explicit enough
+## Covered functions: graphics::par()
+plotOpt <- function (...) graphics::par(..., no.readonly = TRUE)
+plotOptAll <- function (...) graphics::par(..., no.readonly = FALSE)
+#clip() # Set clipping region in the graph
+
+## The plot.xxx() functions...
+## Covered functions: graphics::plot.new(), graphics::frame()
+plotNew <- graphics::plot.new # () and synonym to frame() that is ambiguous => don't use it
+
+## The simple dividing of equidistant boxes is done using plotOpt(mfrow) & plotOpt(mfcol)
+
+## The layout() mechanism
+## Covered functions: graphics::layout(), graphics::layout.show()
+#layout()
+layoutShow <- graphics::layout.show
+
+## The screen() mechanism
+## Covered functions: graphics::split.screen(), graphics::screen()
+## graphics::erase.screen(), graphics::close.screen()
+screenSplit <- graphics::split.screen
+screenSet <- graphics::screen
+screenDelete <- graphics::erase.screen
+screenClose <- graphics::close.screen
+
+## Dimensions
+## Covered functions: graphics::lcm(), graphics::xinch(), graphics::yinch(),
+## graphics::xyinch(), graphics::grconvertX(), graphics::grconvertY()
+#lcm() # Take a number "x" and returns a string with "x cm"
+# Note: __ is used to denote the units, like lenght__cm
+l__cm <- graphics::lcm
+#xinch(), yinch() and xyinch() convert from inch to plot units
+x__in2user <- graphics::xinch
+y__in2user <- graphics::yinch
+xy__in2user <- graphics::xyinch
+#Same for cm2user
+x__cm2user <- function (x = 1, warn.log = TRUE)
+	x__in2user(x = x / 2.54, warn.log = warn.log)
+y__cm2user <- function (y = 1, warn.log = TRUE)
+	y__in2user(y = y / 2.54, warn.log = warn.log)
+xy__cm2user <- function (xy = 1, warn.log = TRUE)
+	xy__in2user(xy = xy / 2.54, warn.log = warn.log)
+## grconvertX() and grconvertY() do not allow metric units,
+## plus there is no grcxonvertXY()
+## TODO: eliminate mm here!
+xConvert <- function (x, from = "user", to = "user")
+{
+	## Perform conversion from cm or mm to inches in from, if needed
+	x <- switch(from,
+		cm = x / 2.54,
+		mm = x / 25.4,
+		x)
+	if (from %in% c("cm", "mm")) from <- "inches"
+	if (to %in% c("cm", "mm")) {
+		res <- graphics::grconvertX(x = x, from = from, to = "inches")
+		if (to == "cm") res <- res * 2.54 else res <- res * 25.4
+		return(res)
+	} else return(graphics::grconvertX(x = x, from = from, to = to))
+}
+
+yConvert <- function (y, from = "user", to = "user")
+{
+	## Perform conversion from cm or mm to inches in from, if needed
+	y <- switch(from,
+		cm = y / 2.54,
+		mm = y / 25.4,
+		y)
+	if (from %in% c("cm", "mm")) from <- "inches"
+	if (to %in% c("cm", "mm")) {
+		res <- graphics::grconvertY(y = y, from = from, to = "inches")
+		if (to == "cm") res <- res * 2.54 else res <- res * 25.4
+		return(res)
+	} else return(graphics::grconvertY(y = y, from = from, to = to))
+}
+
+xyConvert <- function (x, y, from = "user", to = "user")
+{
+	## Either x and y are provided, or x is a list with $x and $y
+	if (missing(y)) {
+		if (!is.list(x) && names(x) != c("x", "y"))
+			stop("You must provide a list with 'x' and 'y', or two vectors")
+		y <- x$y
+		x <- x$x
+	}
+	return(list(
+		x = xConvert(x = x, from = from, to = to),
+		y = yConvert(y = y, from = from, to = to)))
+}
+
+## Basic drawing functions in the graphics package
+#points() # generic
+#lines() # generic
+#matpoints()
+#matlines()
+#abline()
+#segments()
+#arrows()
+#polygon()
+#polypath()
+#curve()
+#rect()
+## TODO: add circle() and ellipse()??? from ellipse package!
+## ellipse there is a generic function to draw confidence region for two parameters
+## It is: ellipse <- function (x, ...) UseMethod("ellipse")
+## => use ovals() and circles() instead???
+## There are draw.circle() and draw.ellipse() in the plotrix package
+#box()
+# axis() and Axis() as an exception!
+#axTicks() in graphics versus axisTicks() in grDevices => forgot about the former?
+#grid() # TODO: rename this to avoid confusion with the grid graphic system?
+#rug()
+#text() # generic
+#mtext()
+#title()
+#legend()
+# Note: graphics::strwidth() and graphics::strheight() are treated in character.R!
+#symbols()
+#rasterImage() # Leave like it is?
+## Problem with contour() # generic, add items to a graph when using add = TRUE
+## We want the same mechanisms as for plot() vs points()/lines()... So, here,
+## we must redefine a generic for that!
+ctrlines <- function (x, ...) UseMethod("ctrlines")
+ctrlines.default <- graphics::contour.default; formals(ctrlines.default)$add <- TRUE
+## See also the shape package!
+## qqlines() from stats
+## plot() method of density object in stats + plot() method of hclust objects
+
+## High-level plot function in the graphics package
+## Covered functions: graphics::filled.contour(), graphics::dotchart(),
+## graphics::smoothScatter(), graphics::stars(), graphics::stem(),
+## graphics::stripchart(), graphics::contour()
+#plot() # generic
+#hist() # generic
+#pie() # Exception, because pieplot() does not exist in English
+#image() # generic # Exception: instead of imageplot() or so?
+#   + heat.colors(), terrain.colors() and topo.colors() from grDevices!
+#pairs() # generic # TODO: define pairsplot()?
+#persp() # generic # TODO: define persplot()? + perspx() in plotrix!?
+#matplot()
+#barplot() # generic
+#boxplot() # generic
+#contour() # generic, create a graph when using default add = FALSE; contourplot() in lattice!
+ctrplot <- graphics::contour
+filledplot <- graphics::filled.contour
+starplot <- graphics::stars
+stemplot <- graphics::stem
+stripplot <- graphics::stripchart
+clevelandplot <- graphics::dotchart
+smoothplot <- graphics::smoothScatter
+#coplot()
+#fourfoldplot()
+#cdplot() # generic
+#mosaicplot() # generic
+#spineplot() # generic
+#sunflowerplot() # generic
+#assocplot() with a better version in vcd as assoc()!
+#+vectorplot() in vectorplot.R!
+## + qqplot()/qqnorm() from stats
+## + screeplot() + biplot()
+
+## Panel functions and other utilities
+## Problem: panel is used in lattice => rename this here?
+## Covered functions: graphics::panel.smooth(), graphics::co.intervals()
+## + panel.hist() and panel.cor() in ?pairs example
+## one way to differentiate them, is to use panel at the end here, like plot
+smoothPanel <- graphics::panel.smooth
+## TODO: rework the various panel.XXX function in panels.R, panels.diag.R & pcomp.R!
+coplotIntervals <- graphics::co.intervals
+
+## Graphic interaction in the graphics package
+#locator()
+#identify() # generic
+
+## "Internal" function in graphics package (normally not for the end-user)
+# Not normally called by the end-user
+## Covered functions: graphics::plot.window(), graphics::plot.xy(),
+## graphics::.filled.contour(), graphics::bxp(), 
+plotWindowInternal <- graphics::plot.window
+plotInternal <- graphics::plot.xy
+boxplotInternal <- graphics::bxp
+filledplotInternal <- graphics::.filled.contour
+
+
+## grDevices ###################################################################
+
+## Devices management
+devNew <- grDevices::dev.new
+devCur <- grDevices::dev.cur
+devList <- grDevices::dev.list
+devNext <- grDevices::dev.next; formals(devNext)$which <- quote(devCur())
+devPrev <- grDevices::dev.prev; formals(devPrev)$which <- quote(devCur())
+devSet <- grDevices::dev.set; formals(devSet)$which <- quote(devNext())
+devClose <- grDevices::dev.off; formals(devClose)$which <- quote(devCur())
+devCloseAll <- grDevices::graphics.off
+devControl <- grDevices::dev.control
+devHold <- grDevices::dev.hold
+devFlush <- grDevices::dev.flush
+devCopy <- grDevices::dev.copy
+devCopyNew <- grDevices::dev.print
+devCopyEps <- grDevices::dev.copy2eps
+devCopyPdf <- grDevices::dev.copy2pdf
+devCopyBitmap <- grDevices::dev2bitmap
+devSave <- grDevices::savePlot
+devRecord <- grDevices::recordPlot
+devReplay <- grDevices::replayPlot
+devCapture <- grDevices::dev.capture
+#devAskNewPage()
+## For devSize, default unit is "cm" instead of "in" for dev.size()
+devSize <- grDevices::dev.size; formals(devSize)$units <- c("cm", "in", "px")
+devCapabilities <- grDevices::dev.capabilities
+devInteractive <- grDevices::dev.interactive
+isDevInteractive <- grDevices::deviceIsInteractive
+
+## Graphic devices
+if (.Platform$OS.type == "unix") {
+	devX11 <- grDevices::X11 # + x11()
+	devX11Opt <- grDevices::X11.options
+}
+if (grepl("^mac", .Platform$pkgType)) {
+	devQuartz <- grDevices::quartz
+	devQuartzOpt <- grDevices::quartz.options
+	## There is a quartz.save() function defined somewhere!
+}
+if (.Platform$OS.type == "windows") {
+	devWin <- grDevices::windows
+	devWinOpt <- grDevices::windows.options
+	devWinPrint <- grDevices::win.print
+	devWinMetafile <- grDevices::win.metafile
+	devToTop <- grDevices::bringToTop # TODO: a similar function for Linux and Mac OS X!
+	formals(devToTop)$which <- quote(devCur())
+	# this is bringToTop(which = dev.cur(), stay = FALSE) # with -1 is console
+	devMsg <- grDevices::msgWindow
+	formals(devMsg)$which <- quote(devCur()) # TODO: a similar function for Linux and Mac OS X
+	# this is msgWindow(type = c("minimize", "restore", "maximize", "hide", "recordOn", "recordOff"),
+    #	which = dev.cur()
+	#recordGraphics(expr, list, env) # A function intended *only* for experts
+}
+devPdf <- grDevices::pdf
+devPdfOpt <- grDevices::pdf.options
+devPS <- grDevices::postscript
+devPSOpt <- grDevices::ps.options
+#setEPS()
+#setPS()
+devPdfCairo <- grDevices::cairo_pdf
+devPSCairo <- grDevices::cairo_ps
+devSvg <- grDevices::svg
+devBmp <- grDevices::bmp
+devJpeg <- grDevices::jpeg
+devPng <- grDevices::png
+devTiff <- grDevices::tiff
+devBitmap <- grDevices::bitmap
+devXfig <- grDevices::xfig
+#pictex() # device, historical interest only
+
+## Color management
+#palette() # get or set the color palette
+#colors() and colours() for a list of color names
+color2rgb <- grDevices::col2rgb # convert colors to rgb
+#rgb()
+#rgb2hsv()
+#hsv()
+#hcl()
+#gray() and grey()
+colorAdjust <- grDevices::adjustcolor
+#colorRamp() and colorRampPalette() to create color ramps
+colorDens <- grDevices::densCols
+## Predefined color sets
+colorBlues9 <- grDevices::blues9
+colorRainbow <- grDevices::rainbow
+colorHeat <- grDevices::heat.colors
+colorTerrain <- grDevices::terrain.colors
+colorTopo <- grDevices::topo.colors
+colorCM <- grDevices::cm.colors
+colorCWM <- cwm.colors
+colorRWB <- rwb.colors
+colorRYG <- ryg.colors
+colorGray <- grDevices::gray.colors
+colorGrey <- grDevices::grey.colors
+## colorConverter object
+#colorConverter()
+colorConverterRgb <- grDevices::make.rgb
+colorConvert <- grDevices::convertColor
+
+## Fonts
+type1Font <- grDevices::Type1Font
+cidFont <- grDevices::CIDFont
+psFonts <- grDevices::postscriptFonts
+#pdfFonts()
+#embedFonts()
+#if (.Platform$OS.type == "windows") {
+#	#windowsFont()
+#	#windowsFonts()
+#}
+#if (grepl("^mac", .Platform$pkgType)) {
+#	#quartzFont()
+#	#quartzFonts()
+#}
+#if (.Platform$OS.type == "unix") {
+#	#X11Font()
+#	#X11Fonts()
+#}
+
+## raster objects
+## TODO: a raster() function to create such an object
+#as.raster()
+#is.raster()
+#+ rasterImage() in the package graphics to draw such a raster object in a plot
+
+## Graphic events
+## TODO: change to: devEvent, devEventHandlers, devEventEnv, devEventEnv<-
+#getGraphicsEvent()
+#setGraphicsEventHandlers()
+#getGraphicsEventEnv()
+#setGraphicsEventEnv()
+
+## Graphic annotations
+#as.graphicsAnnot()
+
+## Utility functions
+checkOpt <- grDevices::check.options #utility function to check options consistency!
+nclassSturges <- grDevices::nclass.Sturges
+nclassScott <- grDevices::nclass.scott
+nclassFD <- grDevices::nclass.FD
+#chull()
+#contourLines()
+#trans3d() # transform from 3d to 2d
+rangeExtend <- grDevices::extendrange
+#pretty() from base => rangePretty()? but a generic function!
+#axisTicks(), .axisPars()
+boxplotStats <- grDevices::boxplot.stats
+#xyTable() # Used by sunflowerplot()
+xyCoords <- grDevices::xy.coords
+xyzCoords <- grDevices::xyz.coords
+in2cm <- grDevices::cm
+cm2in <- function (x) x / cm(1)
+#n2mfrow() computes sensible mfrow from number of graphs
+# + .ps.prolog
+
+## Dynamite plot by Samule Brown
+## http://www.r-bloggers.com/dynamite-plots-in-r/
+## Much critisize! See http://emdbolker.wikidot.com/blog%3Adynamite
+## http://pablomarin-garcia.blogspot.co.nz/2010/02/why-dynamite-plots-are-bad.html
+## http://biostat.mc.vanderbilt.edu/wiki/pub/Main/TatsukiKoyama/Poster3.pdf
+## TODO: find a better representation for ANOVE; al least both hgh ad low wiskers
+## or superpose points, or vioplot, or...?
+#dynamitePlot <- function (height, error, names = NA, significance = NA,
+#ylim = c(0, maxLim), ...)
+#{
+#    maxLim <- 1.1 * max(mapply(sum, height, error))
+#    bp <- barplot(height, names.arg = names, ylim = ylim, ...)
+#    arrows(x0 = bp, y0 = height, y1 = height + error, angle = 90)
+#    text(x = bp, y = 0.2 + height + error, labels = significance)
+#}
+#Values <- c(1, 2, 5, 4)
+#Errors <- c(0.25, 0.5, 0.33, 0.12)
+#Names <- paste("Trial", 1:4)
+#Sig <- c("a", "a", "b", "b")
+#dynamitePlot(Values, Errors, names = Names, significance = Sig)

Modified: pkg/SciViews/R/misc.R
===================================================================
--- pkg/SciViews/R/misc.R	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/SciViews/R/misc.R	2012-04-15 21:37:40 UTC (rev 465)
@@ -1,27 +1,19 @@
 ## A series of functions defined or redefined for a simpler or better use of R
+## Note to get a function, but change its default parameters, use:
+## fun2 <- fun
+## formals(fun2)$arg <- newDefaultValue
 
 # is.wholenumber(), see ?as.integer => define isWholeInt?
 
 ## A convenient starting object for holding items: . == .GlobalEnv
 ## TODO: take care there is no clash with proto objects!
-. <- base::.GlobalEnv
+#. <- base::.GlobalEnv
 
-## This should be nice:
-## Define a valid method to be applied to S3 objects to make sure they are
-## correct
-valid <- function (object, ...)
-	UseMethod("valid")
-	
-valid.default <- function (object, ...)
-	return(object)
+## Testing is.null(obj) is not enough to decide if an object is empty, because
+## there may be like numeric(0), character(0), etc. The right way to do so is
+## to use if (!length(obj)), but it would be more intuitive to define:
+isEmpty <- function (x) return(!length(x))
 
-## A concise construct to make shure we return the right object	
-ifValid <- function (x, what, is.not = stop("need a ", what, " object"))
-	return(if (inherits(x, what)) valid(x) else is.not)
-# res <- ifValid(obj, "class")
-## or in a function
-# return(ifValid(obj, "class"))
-
 ifElse <- get("ifelse", envir = baseenv())
 
 `%else%` <- function (test, expr) if (test) return(invisible()) else expr
@@ -34,8 +26,7 @@
 # res <- try(...., silent = TRUE)
 # if (inherits(res, "try-error")) stop(msg)
 
-enum <- function (x)
-	return(seq_along(x))
+enum <- function (x) return(seq_along(x))
 
 ## Defines only increasing integer sequences
 `%:%` <- function (lower, upper)
@@ -58,13 +49,6 @@
 	if (!res) return(error) else return(invisible(res))
 }
 
-## Environments management
-## Usually, to create an object, we use its name, but
-## environment() means something else here!
-## So, OK, we'll stick with
-newEnv <- get("new.env", envir = baseenv())
-## for the moment...
-
 ## Now, we want to be able to use names() on it too!
 ## Note that for environments, we got items by alphabetic order
 ## => not exactly the same as for vector, list, or so!
@@ -73,18 +57,95 @@
 ## Do we implement `names<-` for environments???
 
 ## Simpler names for often used functions
-n <- get("length", envir = baseenv())
-nc <- get("NCOL", envir = baseenv())
-nr <- get("NROW", envir = baseenv())
+n <- base::as.numeric # TODO: define a "n" object?
+i <- base::as.integer
+## 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
+l <- base::length
+nc <- base::NCOL
+nr <- base::NROW
+
 ## Constants (must start with an uppercase letter)
 ## => redefine Pi instead of pi
-Pi <- get("pi", envir = baseenv())
+Pi <- base::pi
 ## Useful for apply() familly:
 Rows <- 1
 Cols <- 2
 ## Instead of apply(x, 2, sum), it gives apply(x, Cols, sum)
 
+## I don't like isTRUE, because if there is an attribute attached to TRUE,
+## it returns FALSE! =>
+asTRUE <- function (x) identical(TRUE, as.logical(x))
+isFALSE <- function (x) identical(FALSE, x)
+asFALSE <- function (x) identical(FALSE, as.logical(x))
+
+## How to simplify the use of if() by limiting possible special cases?
+## use of any() and all() is there to cope with this, but still:
+## 1) any(NA) => NA, unless any(NA, na.rm = TRUE) => FALSE
+## 2) any(NULL) & any(logical(0)) => FALSE => OK
+## We solve this by defining any.() and all.()
+any. <- function (..., na.rm = TRUE) any(..., na.rm = na.rm)
+all. <- function (..., na.rm = TRUE) all(..., na.rm = na.rm)
+one <- function (x, na.rm = FALSE) UseMethod("one")
+## Same as asTRUE(), but slower, because it is a method
+one.default <- function (x, na.rm = FALSE)
+{
+	if (isTRUE(na.rm)) x <- na.omit(x)
+	return(identical(TRUE, as.logical(x)))
+}
+one. <- function (x, na.rm = TRUE) one(x, na.rm = na.rm)
+stopIfNot <- base::stopifnot
+
+## TODO: other xxx. functions for those using na.rm = FALSE
+## like mean, median, sd, var, quantile, fivenum, ...
+
+`%is%` <- function (x, class) is(x, as.character(substitute(class)))
+`%as%` <- function (x, class) as(x, as.character(substitute(class)))
+
+#s1 <- 12.3
+#s1 %is% numeric
+#s1 %is% integer
+#s1 %as% integer %is% integer
+
+## Ternary condition statement, like in JavaScript cond ? yes : no
+## Not possible to do in R... but the closest is:
+`%?%` <- function (cond, yes.no) { if (cond) yes.no[1] else yes.no[2] }
+## ... and its vectorized conterpart:
+`%??%` <- function (cond, yes.no) ifelse(cond, yes = yes.no[1], no = yes.no[2])
+
+TRUE %?% c(1, 2)
+FALSE %?% c(yes = 1, no = 2)
+x <- 1:3
+res <- any(x > 2) %?% c("yes", "no"); res
+res <- (x > 2) %??% c("yes", "no"); res # Take care of parentheses!
+rm(x, res)
+
+## It is common to test if something is zero, or one... Here, the non vectorized
+## version asks for all items being zero or one, excluding missing data!
+## TODO: good idea (perhaps)... but this does not work well!
+#`%?0%` <- function (x, yes.no) { if (all.(x == 0)) yes.no[1] else yes.no[2] }
+#`%?1%` <- function (x, yes.no) { if (all.(x == 1)) yes.no[1] else yes.no[2] }
+#`%??0%` <- function (x, yes.no) ifelse(x == 0, yes = yes.no[1], no = yes.no[2])
+#`%??1%` <- function (x, yes.no) ifelse(x == 1, yes = yes.no[1], no = yes.no[2])
+
+#x <- 1; x %?0% c(yes = stop("x must be non null"), no = x^2)
+#x <- 0; x %?0% c(yes = stop("x must be non null"), no = x^2)
+## This helps to construct sentences with single or plural
+#x <- 1; rep(x, 3) %??1% c(single = c("There is ", 1, " item in x"),
+#	plural = c("There are ", length(x), " items in x"))
+#x <- 3; rep(x, 3) %??1% c(single = c("There is ", 1, " item in x"),
+#	plural = c("There are ", length(x), " items in x"))
+
+
+## Should we keep these without renaming???
+#na.action()
+#na.omit()
+#na.fail()
+#na.exclude()
+#na.pass()
+## And what to do with naresid() and napredict()?
+
 ## Problem of functional language like R: too much copy!
 ## For instance, change a simple attribute using attr(x) <- value
 ## leads to a copy of the object.... If the object is large, time
@@ -181,7 +242,7 @@
 #			})
 		stop(":= cannot be used directly on an object")
 	}
-	## If a more complex is provided, try to run `fun:=` instead
+	## If a more complex call is provided, try to run `fun:=` instead
 	X <- as.pairlist(substitute(X))
 	## To emulate `fun<-`, but using `fun:=`
 	fun <- paste(deparse(X[[1]]), ":=", sep = "")
@@ -241,7 +302,11 @@
 #htestPropTrend <- prop.trend.test
 #htestShapiroWilk <- shapiro.test
 
+#all.names
+#all.vars
 
+#Data and POSIXct
+
 #contrHelmert <- contr.helmert
 #contrPoly <- contr.poly
 #contrSum <- contr.sum
@@ -251,15 +316,6 @@
 #equal <- all.equal
 #equalA <- attr.all.equal
 
-#baseEnv <- baseenv
-#emptyEnv <- emptyenv
-#globalEnv <- globalEnv
-#parentEnv <- parent.env
-#`parentEnv<-` <- `parent.env<-`
-##TODO: use tempEnv instead of TempEnv?
-
-#evalParent <- eval.parent
-
 #expandGrid <- expand.grid
 
 #gcTiming <- gc.time + return a difftime object
@@ -267,25 +323,24 @@
 #gcTorture <- gctorture
 #??? gcTorture2 <- gctorture2
 
-#inverseRle <- inverse.rle or rleInverse?
+#rleInverse <- inverse.rle
 
-#isAtomic <- is.atomic
-#isCall <- is.call??
+#No -> isAtomic <- is.atomic
+#No -> isCall <- is.call??
 #isElement <- is.element
 #?isExpression??
 #isFinite <- is.finite
-#isLanguage <- is.language
+#No -> isLanguage <- is.language
 #isLoaded <- is.loaded
 #isNA <- is.na
 #isNaN <- is.nan
 #isNULL <- is.null
 #isR <- is.R
-#isRecursive <- is.recursive
-#isSymbol <- is.symbol
+#No -> isRecursive <- is.recursive
+#No -> isSymbol <- is.symbol
 #isUnsorted <- is.unsorted
-#isVector <- is.vector
+#No -> isVector <- is.vector
 #isTTY <- isatty
-#isDebugged <- isdebugged
 
 #l10n.info?
 #list2env should be as.environment() applied to list, really
@@ -293,7 +348,6 @@
 #mat.or.vec
 #maxCol <- max.col... or colMax, cf. colSum
 #average() as a simpler version than mean() for fast run
-#onExit <- on.exit
 
 #qrX <- qr.X
 #qrQ <- qr.Q
@@ -309,8 +363,8 @@
 #setdiff & other setxxx functions
 
 #dateCurrent <- Sys.Date
-#Sys.getenv, Sys.getlocale, Sys.getpid, Sys.info, Sys.localeconv, sys.on.exit
-#sys.parent, Sys.setenv, Sys.setlocale, sys.source, sys.status
+#Sys.getenv, Sys.getlocale, Sys.getpid, Sys.info, Sys.localeconv
+#Sys.setenv, Sys.setlocale
 #timeCurrent <- Sys.time
 #Sys.timezone, Sys.unsetenv
 
@@ -318,6 +372,128 @@
 #upperTri <- upper.tri
 
 #utf8ToInt
+#cStackInfo <- base::Cstack_info
+#.Internal() triggers notes => what to do?
+#.Primitive()
 
+## Read this carefully before rethinking these function, trying to simplify a bit things:
+## http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/
+## Environments management
+## Use of frame as a synonym of environment brings an additional difficulty on
+## an already difficult subject! => use env(ironment) everywhere?!
+## TODO: all these sys.xxx must remain like this!
+sysFunction <- base::sys.function
+sysCall <- base::sys.call
+sysCalls <- base::sys.calls
+matchCall <- base::match.call
+sysParent <- base::sys.parent
+sysParents <- base::sys.parents
+## TODO: do not use frame => what??? sys.prevEnv()??
+parentFrame <- base::parent.frame
+sysFrame <- base::sys.frame
+sysFrames <- base::sys.frames
+sysnFrame <- base::sys.nframe
+sysStatus <- base::sys.status
+onExit <- function (expr = NULL, add = FALSE) base::on.exit(expr = expr, add = add)
+sysOnExit <- base::sys.on.exit
+dumpFrames <- utils::dump.frames
+#debugger(dump = last.dump) # utils
+#browser()
+#browserText()
+#browserCondition()
+#browserSetDebug()
+#debug()
+#undebug()
+debugOnce <- base::debugonce
+isDebugged <- base::isdebugged
+baseEnv <- base::baseenv
+.BaseEnv <- base::baseenv()
+baseNamespaceEnv <- function () return(.BaseNamespaceEnv)
+#.BaseNamespaceEnv already defined
+## Those four environments are specials and start with an uppercase letter!
+emptyEnv <- base::emptyenv
+.EmptyEnv <- base::emptyenv()
+globalEnv <- base::globalenv # Also .GlobalEnv
+# .GlobalEnv already defined
+autoloadEnv <- function () return(.AutoloadEnv)
+#.AutoloadEnv already defined
+#TempEnv() in svMisc
+tempEnv <- svMisc::TempEnv
+.TempEnv <- svMisc::TempEnv()
+## TODO: or sys.topEnv()???
+topEnv <- base::topenv
+# Usually, to create an object, we use its name, but
+## environment() means something else here!
+## So, OK, we'll stick with:
+environmentNew <- base::new.env
+## Should not be used!
+environmentParent <- base::parent.env
+`environmentParent<-` <- base::`parent.env<-`
+#environmentName()
+#environment()
+#`environment<-`()
+#is.environment()
+environmentProfile <- base::env.profile
+## name attribute to an environment,... see ?environment
+#source()
 
+sysSource <- base::sys.source
+#.First.sys and .Last.sys cannot be changed!
+#eval()
+evalQuote <- base::evalq
+evalParent <- base::eval.parent
+evalLocal <- base::local
 
+autoloaded <- function () return(.Autoloaded)
+#autoload()
+#autoloader()
+#delayedAssign()
+
+## This is the options() mechanism:
+## I don't like the options("width") returning a list with only $width in it!
+## I want a mechanisms much like par("ask") which directly returns the value, thus:
+### Covered function: base::options(), base::getOption(), base::.Options
+opt <- function (...) {
+	arg <- list(...)
+	l <- length(arg)
+	if (l == 0) {
+		return(options()) # List of all options
+	} else if (l == 1 && is.null(names(arg))) {
+		return(options(...)[[1]]) # The value for this option
+	} else return(invisible(options(...))) # Invisible list of previous options
+}
+## With a single argument, opt() and optDef() give the same thing, but
+## optDef() allows to provide a default value for the option, if not found
+optDef <- getOption # (x, default = NULL)
+
+
+## For R help on the web:
+## http://rseek.org
+## http://www.r-project.org/mail.html for mailing lists
+## StackOverflow http://stackoverflow.com/questions/tagged/r
+## #rstats Twitter hashtag http://search.twitter.com/search?q=%23rstats
+## R-Bloggers http://www.r-bloggers.com
+## Video Rchive (of presentations) http://www.vcasmo.com/user/drewconway
+
+## Useful packages from "machine learning for hackers"
+## arm, glmnet, ggplot2, igraph, lme4, lubridate, RCurl, plyr, RJSONIO, spatstat, RSXML
+
+## ! is not defined for character strings... Use it here for quick conversion
+## of character into an "s" (string) object... Used in doc blocks for an R script
+## compatible with Sweave
+`!` <- function(x) if (is.character(x))
+	structure(x, class = c("s", "character")) else .Primitive("!")(x)
+
+## The print.s method is designed to print nothing in case of a doc block
+## TODO: need methods to convert these into Html or Pdf for quick view!
+## TODO: a method to check correctness of these blocks for Asciidoc blocks
+## (for LaTeX blocks, it would not work)
+print.s <- function (x, ...)
+{
+	## If the string starts with @\n and ends with <<.*>>=,
+	## treat it specially (it is a doc chunk!): print just nothing!
+	if (grepl("^@[ \t]*\n.*<<[^\n]*>>=[ \t]*$", x)) {
+		cat("<...doc chunk...>\n")
+	} else print(as.character(x))
+	return(invisible(x))
+}

Modified: pkg/svSweave/DESCRIPTION
===================================================================
--- pkg/svSweave/DESCRIPTION	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/svSweave/DESCRIPTION	2012-04-15 21:37:40 UTC (rev 465)
@@ -1,14 +1,15 @@
 Package: svSweave
 Type: Package
-Version: 0.9-3
-Date: 2011-11-27
+Version: 0.9-4
+Date: 2012-04-12
 Title: SciViews GUI API - Sweave functions
 Authors at R: c(person("Philippe", "Grosjean", role = c("aut", "cre"),
   email = "phgrosjean at sciviews.org"))
 Author: Philippe Grosjean
 Maintainer: Philippe Grosjean <phgrosjean at sciviews.org>
-Depends: R (>= 2.6.0)
+Depends: R (>= 2.6.0), ascii
 Imports: utils
+SystemRequirements: Python (>= 2.4) to run Asciidoc (http://www.python.org/)
 Description: Supporting functions for the GUI API (Sweave functions)
 License: GPL-2
 URL: http://www.sciviews.org/SciViews-R

Modified: pkg/svSweave/NAMESPACE
===================================================================
--- pkg/svSweave/NAMESPACE	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/svSweave/NAMESPACE	2012-04-15 21:37:40 UTC (rev 465)
@@ -1,5 +1,9 @@
-import(utils)
+import(utils, ascii)
 
 export(cleanLyxRnw,
        tangleLyxRnw,
-       weaveLyxRnw)
+       weaveLyxRnw,
+       RasciidocToRnw,
+       RasciidocToHtml,
+       RasciidocThemes,
+       svBuild)

Modified: pkg/svSweave/NEWS
===================================================================
--- pkg/svSweave/NEWS	2012-04-04 16:55:01 UTC (rev 464)
+++ pkg/svSweave/NEWS	2012-04-15 21:37:40 UTC (rev 465)
@@ -1,5 +1,21 @@
 = svSweave News
 
+== Changes in svSweave 0.9-4
+
+* Added a dependence to the ascii package to support Asciidoc Sweave documents.
+
+* Asciidoc 8.6-7 is installed with the package but it will only work if
+  Python >= 2.4 is installed. Asciidoc is distributed under a GPL-2 license,
+  like the package.
+  
+* RasciidocToRnw() and RasciidocToHtml() added to convert SciViews R scripts
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/sciviews -r 465


More information about the Sciviews-commits mailing list