Learn R Programming

PBSmodelling (version 2.68.6)

talk-class: S4: Present Talk Classes

Description

The function presentTalk is a tool that facilitates lectures and workshops in R. It allows the presenter to show code snippets alongside their execution, making use of R's graphical capabilities.

For presentTalk to work, six S4 class objects are created:

talk......root element that constitutes a talk; section...branch element that defines a section within a talk; text......leaf element that specifies text to be printed on the R console; file......leaf element that specifies files to be opened by the OS; code......leaf element that specifies R code to be executed; break.....leaf element that specifies where to allow a break in the talk.

The leaf elements, also termed primitive elements, occur in isolation and cannot contain other elements. Therefore, only two levels of nesting are supported: sections within a talk and primitives within a section. See Appendix B in the PBSmodelling User's Guide for more information.

Arguments

Slots Available

talk
name character string giving the name of the talk (required)
sections list list of sections within the talk
files list list of files within the talk
section
name character string giving the name of the section (required)
items list list of the four primitive (leaf-element) S4 classes
button logical should GUI have a button that selects section?
col integer column in lower section of GUI to place button
section_id integer specify if section does not immediately follow a talk
text
text character text to display on the R console
"break" logical break the presentation after displaying the text specified?
file
name character string giving the name in the GUI for a group of files to open (required)
filename character individual file names associated with the group name in the GUI
"break" logical break the presentation after opening the group of files?
button logical should GUI add a button that opens this group of files?
col integer column in lower section of GUI to place button
code
show logical show the code snippet in the R console?
print logical print the results of running the R code?
code character the actual chunk of R code
"break" character string describing where to introduce breaks in the code segment
eval logical evaluate the R code?
break

Creating S4 Objects

Objects can be created by calls of the form:

new("talk", name=name)
new("section",
  name     = node$attributes["name"],
  button   = as.logical(xmlGetAttr(node,"button",FALSE)),
  col      = as.integer(xmlGetAttr(node,"col",2)))
new("text", 
  text     = xmlValue(node),
  "break"  = as.logical(xmlGetAttr(node,"break",TRUE)))
new("file",
  name     = xmlGetAttr(node,"name",""), 
  "break"  = as.logical(xmlGetAttr(node,"break",TRUE)),
  filename = xmlValue(node),
  button   = as.logical(xmlGetAttr(node,"button",FALSE)),
  col      = as.integer(xmlGetAttr(node,"col",3)))
new("code",
  show     = as.logical(xmlGetAttr(node,"show",TRUE)), 
  print    = as.logical(xmlGetAttr(node,"print",TRUE)), 
  code     = xmlValue(node), 
  "break"  = tolower(xmlGetAttr(node,"break","print")))
new("break") 

Details

This function uses a convenience function called xmlGetAttr (from the package XML) that retrieves the value of a named attribute in an XML node.

The function presentTalk translates the XML code into a list structure called .presentTalk below the global object .PBSmod. The GUI is represented as a list structure called presentwin under .PBSmod, as for all GUI objects in PBSmodelling.

See Also

presentTalk for presenting a talk in R.

xmlGetAttr for retrieving the value of a named attribute in an XML node.

setClass for creating a class definition.

PBSoptions-class for a complicated S4 class implementation.