Package brew. February 19, 2015

Similar documents
Package hive. July 3, 2015

Package TSfame. February 15, 2013

Package hive. January 10, 2011

Package HadoopStreaming

Package httprequest. R topics documented: February 20, 2015

Package retrosheet. April 13, 2015

Package sendmailr. February 20, 2015

Package packrat. R topics documented: March 28, Type Package

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Package sjdbc. R topics documented: February 20, 2015

Oracle Forms Services Secure Web.Show_Document() calls to Oracle Reports

Package TimeWarp. R topics documented: April 1, 2015

Package RCassandra. R topics documented: February 19, Version Title R/Cassandra interface

Package uptimerobot. October 22, 2015

Package empiricalfdr.deseq2

PHP Debugging. Draft: March 19, Christopher Vickery

Package PKI. July 28, 2015

Getting Started with the Internet Communications Engine

Package fimport. February 19, 2015

Top 72 Perl Interview Questions and Answers

The C Programming Language course syllabus associate level

Oracle Forms Services Secure Web.Show_Document() calls to Oracle Reports Server 6i

Package plan. R topics documented: February 20, 2015

Package PKI. February 20, 2013

Command Line Interface User Guide for Intel Server Management Software

COMP 110 Prasun Dewan 1

DOS Command Reference

Package date. R topics documented: February 19, Version Title Functions for handling dates. Description Functions for handling dates.

public static void main(string[] args) { System.out.println("hello, world"); } }

INSTALL NOTES Elements Environments Windows 95 Users

Package tagcloud. R topics documented: July 3, 2015

Advanced Bash Scripting. Joshua Malone

Package dunn.test. January 6, 2016

The New R Help System

CS 1133, LAB 2: FUNCTIONS AND TESTING

Introduction to Synoptic

Package whisker. R topics documented: February 20, 2015

Bitrix Site Manager 4.0. Quick Start Guide to Newsletters and Subscriptions

Accessing Data with ADOBE FLEX 4.6

Ruby On Rails. CSCI 5449 Submitted by: Bhaskar Vaish

Package sudoku. February 20, 2015

HP Operations Orchestration Software

Package xtal. December 29, 2015

CLC Server Command Line Tools USER MANUAL

HP WebInspect Tutorial

List of FTP commands for the Microsoft command-line FTP client

OPEN ESB 2.3 TUTORIAL. Working with FILEBC

Configuring and Monitoring Hitachi SAN Servers

Subversion workflow guide

Programming Languages CIS 443

Member Functions of the istream Class

Package GEOquery. August 18, 2015

Offline Image Viewer Guide

Package translater. R topics documented: February 20, Type Package

Magento Search Extension TECHNICAL DOCUMENTATION

Hadoop Streaming. Table of contents

Oracle BI 11g R1: Build Repositories

Design: Metadata Cache Logging

Configuring a Jetty Container for SESM Applications

Perl version documentation - Digest::SHA NAME SYNOPSIS SYNOPSIS (HMAC-SHA) Page 1

7 Why Use Perl for CGI?

Forensic Analysis of Internet Explorer Activity Files

TIBCO BusinessEvents Business Process Orchestration Release Notes

Typo3 Extension API. mysqldump --password=[password] [database name] [tablename] --add-drop-table >./ext_tables_static.sql

Building a Multi-Threaded Web Server

Application Security Policy

Hive Interview Questions

Package wordnet. January 6, 2016

Package EasyHTMLReport

Package StockChina. January 30, 2016

Package bigdata. R topics documented: February 19, 2015

Computational Mathematics with Python

Fireware How To Authentication

Package VideoComparison

Package pdfetch. R topics documented: July 19, 2015

Administrator's Guide

Using the Synchronization Client

--version Print the version number of GeneTorrent to the standard output stream. This version number should be included in all bug reports.

Package syuzhet. February 22, 2015

Some Scanner Class Methods

In order to understand Perl objects, you first need to understand references in Perl. See perlref for details.

Borland Delphi 6 Product Certification. Study Guide. Version 1.0 Copyright 2001 Borland Software Corporation. All Rights Reserved.

Dove User Guide Copyright Virgil Trasca

Bash shell programming Part II Control statements

Lecture 5: Java Fundamentals III

TIBCO ActiveMatrix BusinessWorks Plug-in for Big Data User s Guide

Microsoft Dynamics GP

CS2720 Practical Software Development

Package hoarder. June 30, 2015

This presentation will discuss how to troubleshoot different types of project creation issues with Information Server DataStage version 8.

by NetMedia, Inc. All rights reserved. Basic Express, BasicX, BX-01, BX-24 and BX-35 are trademarks of NetMedia, Inc. 2.

Package urltools. October 11, 2015

Package DDIwR. R topics documented: February 19, Version Date Title DDI with R Depends R (>= 3.1.0) Imports XML, foreign

KWIC Exercise. 6/18/ , Spencer Rugaber 1

10CS73:Web Programming

Using CertAgent to Obtain Domain Controller and Smart Card Logon Certificates for Active Directory Authentication

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

Eventia Log Parsing Editor 1.0 Administration Guide

VOC Documentation. Release 0.1. Russell Keith-Magee

Package MDM. February 19, 2015

Transcription:

Type Package Package brew February 19, 2015 Title Templating Framework for Report Generation Version 1.0-6 Date 2010-09-30 Author Jeffrey Horner Maintainer Jeffrey Horner <jeffrey.horner@gmail.com> Description brew implements a templating framework for mixing text and R code for report generation. brew template syntax is similar to PHP, Ruby's erb module, Java Server Pages, and Python's psp module. License GPL-2 Repository CRAN Date/Publication 2011-04-13 15:16:08 NeedsCompilation no R topics documented: brew............................................. 1 brewcache......................................... 4 Index 7 brew Report Brewing For Text and R Output Description brew provides a templating system for text reporting. The syntax is similar to PHP, Java Server Pages, Ruby s erb module, and Python s psp module. 1

2 brew Usage brew(file=stdin(),output=stdout(),text=null,envir=parent.frame(), run=true,parsecode=true,tplparser=null,chdir=false) Arguments file output text envir run Details A connection, or a character string naming the file to read from. stdin() is the default. A connection, or a character string naming the file to print to. stdout() is the default. A character string treated as if it contained lines of a file to read from. Only one of file or text is used as input. Default is NULL. the environment in which the input is to be evaluated. Default is the caller s environment, useful for nested brew calls. Logical to determine if brew should evaluate the input (run=true) or just parse it (run=false). Useful for debugging. parsecode Logical. only relevant when run=false. When TRUE the brewed code is parsed and then silently returned. When FALSE, the brewed code is returned as a list. See the Value section for details. tplparser chdir a function to parse the text between <%% and %%> and return the result as a character vector. The template text is passed to the function as a variable length character vector in the first argument position. logical; if TRUE and file is a pathname, the R working directory is temporarily changed to the directory containing file for evaluating. brew will also honor the global option brew.chdir. brew syntax is quite simple and there are very few delimiters to learn: 1.All text that falls outside of the delimiters is printed as-is. 2.R expressions between the <% and %> delimiters are executed in-place. 3.The value of the R expression between the <%= and %> delimiters is printed. 4.All text between the <%\# and %> delimiters is thrown away. Use it as a comment. 5.If you place a - just before the %> delimiter, and it s placed at the end of a line, then the newline is omitted from the output. The following template contains syntax to exercise all brew functionality: --------------- You won t see this R output, but it will run. <% foo <- bar %> Now foo is <%=foo%> and today is <%=format(sys.time(), %B %d, %Y )%>. <%# Comment -- ignored -- useful in testing. Also notice the dash-percent-gt. It chops off the trailing newline.

brew 3 You can add it to any percent-gt. -%> How about generating a template from a template? <%% foo <- fee fi fo fum %%> foo is still <%=foo%>. --------------- The output is: -------------- You won t see this R output, but it will run. Now foo is bar and today is April 20, 2007. How about generating a template from a template? <% foo <- fee fi fo fum %> foo is still bar. -------------- Also, for power users, there s one more thing: 6.Text between the <%% and %%> delimiters is treated as a brew template and is printed as-is, but the delimiters are changed to <% and %>. This happens when tplparser=null. But if tplparser is a valid function, then the text is passed to tplparser which should return a character vector to replace the text. NOTE: brew calls can be nested and rely on placing a function named.brew.cat in the environment in which it is passed. Each time brew is called, a check for the existence of this function is made. If it exists, then it is replaced with a new copy that is lexically scoped to the current brew frame. Once the brew call is done, the function is replaced with the previous function. The function is finally removed from the environment once all brew calls return. Value When run=true, the value of the last expression after brewing the input or an object of class tryerror containing the error message if brewing failed. When run=false and parsecode=true, a function whose environment contains the text vector and the code vector of the parsed expressions after brewing the input. It takes brew s output and envir arguments. When run=false and parsecode=false, a list containing the text vector and the unparsed code vector. Author(s) Jeffrey Horner <jeff.horner@vanderbilt.edu> See Also Sweave for the original report generator.

4 brewcache Examples ## A port of the Sweave test file. brew(system.file("brew-test-1.brew",package="brew"),"brew-test-1.tex",envir=new.env()) ## Everything you wanted to know about your R session. brew(system.file("brew-test-2.brew",package="brew"),"brew-test-2.html",envir=new.env()) browseurl(paste( file://,file.path(getwd(), brew-test-2.html ),sep= )) ## Don t sully up environment, so use envir=new.env(). Nested brew calls will still work. brew(system.file("example1.brew",package="brew"),envir=new.env()) ## Various ways to print R output library(datasets) brew(system.file("catprint.brew",package="brew"),envir=new.env()) rm(iris) ## The example from the Details section brew(system.file("featurefull.brew",package="brew"),envir=new.env()) ## Using the tplparser argument tparse <- function(text) paste( Got this: <,text, >\n,sep=,collapse= ) brew(system.file("featurefull.brew",package="brew"),envir=new.env(),tplparser=tparse) rm(tparse) brewcache Caching Brew Templates Description These functions provide a cache system for brew templates. Usage brewcache(envir=null) brewcacheon() brewcacheoff() setbuflen(len=0) Arguments envir len the environment to store text and R expressions for each brewed template. length of internal buffers for parsing the templates.

brewcache 5 Details Value brew can cache parsed templates for potential speedup but only when brew calls are passed filenames, not connections, and when tplparser is NULL. brew caching is implemented by storing file names, modification times, and the associated text and R expressions in an internal environment. Calling brewcache() with an appropriate environment sets the internal cache. Calling without arguments returns the internal cache. The cache is exposed this way mainly for testing, debugging, performance improvement, etc. and this may be off-limits in future releases. Simple enough, brewcacheon() turns on caching of brew templates and is equivalent to calling brewcache(envir=new.env(hash=true,parent=globalenv())). brewcache() without arguments returns the internal environment. Calling brewcacheoff() turns off caching by setting the internal environment to NULL. One thing to note: filenames act as keys in the internal cache environment, and brew does nothing to expand them to their full paths. Thus, /home/user/brew.html and ~usr/brew.html will act as separate keys, although on-disk they may actually point to the same file. setbuflen() initializes internal parsing vectors to length len. Default is 0. brewcache() without arguments returns the internal cache. All others invisibly return NULL. Author(s) See Also Jeffrey Horner <jeff.horner@vanderbilt.edu> Sweave for the original report generator. Examples ## Turn on caching brewcacheon() ## Brew a template brew(system.file("featurefull.brew",package="brew"),envir=new.env()) ## Get the internal cache cache <- brewcache() ## Inspect as.list(cache) ## Inspect first file cached in list as.list(cache)[[1]] ## Inspect environment that contains text and parsed code as.list(as.list(cache)[[1]]$env)

6 brewcache ## Turn off brew caching brewcacheoff() rm(cache)

Index Topic utilities brew, 1 brewcache, 4 brew, 1 brewcache, 4 brewcacheoff (brewcache), 4 brewcacheon (brewcache), 4 environment, 2, 4 setbuflen (brewcache), 4 Sweave, 3, 5 7