Class: KnitrEngine

Inherits:
Object
  • Object
show all
Defined in:
lib/gknit/knitr_engine.rb

Overview

dir = File.dirname(File.expand_path(‘.’, __FILE__)) src = “#dir/R/eng_ruby.R”

Direct Known Subclasses

IncludeEngine, RbEngine, RubyEngine

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backgroundObject (readonly)

background: (‘#F7F7F7’; character or numeric) background color of chunks in LaTeX output (passed to the LaTeX package framed); the color model is rgb; it can be either a numeric vector of length 3, with each element between 0 and 1 to denote red, green and blue, or any built-in color in R like red or springgreen3 (see colors() for a full list), or a hex string like #FFFF00, or an integer (all these colors will be converted to the RGB model; see ?col2rgb for details)



161
162
163
# File 'lib/gknit/knitr_engine.rb', line 161

def background
  @background
end

#class__outputObject (readonly)

class.output: (NULL; character) useful for HTML output, appends classes that can be used in conjunction with css, so you can apply custom formatting.



114
115
116
# File 'lib/gknit/knitr_engine.rb', line 114

def class__output
  @class__output
end

#class__sourceObject (readonly)

class.source: (NULL; character) useful for HTML output, appends classes that can be used in conjunction with css, so you can apply custom formatting.



165
166
167
# File 'lib/gknit/knitr_engine.rb', line 165

def class__source
  @class__source
end

#collapseObject (readonly)

collapse: (FALSE; logical; applies to Markdown output only) whether to, if possible, collapse all the source and output blocks from one code chunk into a single block (by default, they are written to separate <pre></pre> blocks)



63
64
65
# File 'lib/gknit/knitr_engine.rb', line 63

def collapse
  @collapse
end

#commentObject (readonly)

comment: (‘##’; character) the prefix to be put before source code output; default is to comment out the output by ##, which is good for readers to copy R source code since output is masked in comments (set comment=NA to disable this feature)



144
145
146
# File 'lib/gknit/knitr_engine.rb', line 144

def comment
  @comment
end

#devObject (readonly)

dev: (‘pdf’ for LaTeX output and ‘png’ for HTML/markdown; character) the function

name which will be used as a graphical device to record plots; for the convenience
of usage, this package has included all the graphics devices in base R as well as
those in Cairo, cairoDevice and tikzDevice, e.g. if we set dev='CairoPDF', the
function with the same name in the Cairo package will be used for graphics output;
if none of the 20 built-in devices is appropriate, we can still provide yet another
name as long as it is a legal function name which can record plots
(it must be of the form function(filename, width, height)); note the units for
images are always inches (even for bitmap devices, in which DPI is used to convert
between pixels and inches); currently available devices are bmp, postscript, pdf,
png, svg, jpeg, pictex, tiff, win.metafile, cairo_pdf, cairo_ps, CairoJPEG,
CairoPNG, CairoPS, CairoPDF, CairoSVG, CairoTIFF, Cairo_pdf, Cairo_png, Cairo_ps,
Cairo_svg, tikz and a series of quartz devices including quartz_pdf, quartz_png,
quartz_jpeg, quartz_tiff, quartz_gif, quartz_psd, quartz_bmp which are just
wrappers to the function quartz() with different file types
  • the options dev, fig.ext, fig.width, fig.height and dpi can be vectors (shorter ones will be recycled), e.g. <<foo, dev=c(‘pdf’, ‘png’)>>= creates two files for the same plot: foo.pdf and foo.png



219
220
221
# File 'lib/gknit/knitr_engine.rb', line 219

def dev
  @dev
end

#dev__argsObject (readonly)

dev.args: (NULL) more arguments to be passed to the device, e.g. dev.args=list(bg=‘yellow’, pointsize=10); note this depends on the specific device (see the device documentation); when dev has multiple elements, dev.args can be a list of lists of arguments with each list of arguments to be passed to each single device, e.g. <<dev=c(‘pdf’, ‘tiff’), dev.args=list(pdf = list(colormodel = ‘cmyk’, useDingats = TRUE),

tiff = list(compression = 'lzw'))>>=


228
229
230
# File 'lib/gknit/knitr_engine.rb', line 228

def dev__args
  @dev__args
end

#dpiObject (readonly)

dpi: (72; numeric) the DPI (dots per inch) for bitmap devices (dpi * inches = pixels)



236
237
238
# File 'lib/gknit/knitr_engine.rb', line 236

def dpi
  @dpi
end

#echoObject (readonly)

echo: (TRUE; logical) whether to include Ruby source code in the output file



49
50
51
# File 'lib/gknit/knitr_engine.rb', line 49

def echo
  @echo
end

#errorObject (readonly)

error: (TRUE; logical) whether to preserve errors (from stop()); by default, the evaluation will not stop even in case of errors!! if we want R to stop on errors, we need to set this option to FALSE when the chunk option include = FALSE, error knitr will stop on error, because it is easy to overlook potential errors in this case



77
78
79
# File 'lib/gknit/knitr_engine.rb', line 77

def error
  @error
end

#evalObject (readonly)

eval: (TRUE; logical) whether to evaluate the code chunk



41
42
43
# File 'lib/gknit/knitr_engine.rb', line 41

def eval
  @eval
end

#externalObject (readonly)

external: (TRUE; logical) whether to externalize tikz graphics (pre-compile tikz graphics to PDF); it is only used for the tikz() device in the tikzDevice package (i.e., when dev=‘tikz’) and it can save time for LaTeX compilation



350
351
352
# File 'lib/gknit/knitr_engine.rb', line 350

def external
  @external
end

#fig__alignObject (readonly)

fig.align: (‘default’; character) alignment of figures in the output document (possible values are left, right and center; default is not to make any alignment adjustments); note that for Markdown output, forcing figure alignments will lead to the HTML tag <img /> instead of the original Markdown syntax ![](), because Markdown does not have native support for figure alignments (see #611)



295
296
297
# File 'lib/gknit/knitr_engine.rb', line 295

def fig__align
  @fig__align
end

#fig__aspObject (readonly)

fig.asp: (NULL; numeric) the aspect ratio of the plot, i.e. the ratio of height/width; when fig.asp is specified, the height of a plot (the chunk option fig.height) is calculated from fig.width * fig.asp



246
247
248
# File 'lib/gknit/knitr_engine.rb', line 246

def fig__asp
  @fig__asp
end

#fig__capObject (readonly)

fig.cap: (NULL; character) figure caption to be used in a figure environment in LaTeX (in caption{}); if NULL or NA, it will be ignored, otherwise a figure environment will be used for the plots in the chunk (output in beginfigure and endfigure)



305
306
307
# File 'lib/gknit/knitr_engine.rb', line 305

def fig__cap
  @fig__cap
end

#fig__dimObject (readonly)

fig.dim: (NULL; numeric) if a numeric vector of length 2, it gives fig.width and fig.height, e.g., fig.dim = c(5, 7) is a shorthand of fig.width = 5, fig.height = 7; if both fig.asp and fig.dim are provided, fig.asp will be ignored (with a warning)



252
253
254
# File 'lib/gknit/knitr_engine.rb', line 252

def fig__dim
  @fig__dim
end

#fig__envObject (readonly)

fig.env: (‘figure’) the LaTeX environment for figures, e.g. set fig.env=‘marginfigure’ to get beginmarginfigure



299
300
301
# File 'lib/gknit/knitr_engine.rb', line 299

def fig__env
  @fig__env
end

#fig__extObject (readonly)

fig.ext: (NULL; character) file extension of the figure output (if NULL, it will be derived from the graphical device; see knitr:::auto_exts for details)



233
234
235
# File 'lib/gknit/knitr_engine.rb', line 233

def fig__ext
  @fig__ext
end

#fig__filenameObject (readonly)

Returns the value of attribute fig__filename.



179
180
181
# File 'lib/gknit/knitr_engine.rb', line 179

def fig__filename
  @fig__filename
end

#fig__heightObject (readonly)

Returns the value of attribute fig__height.



241
242
243
# File 'lib/gknit/knitr_engine.rb', line 241

def fig__height
  @fig__height
end

#fig__keepObject (readonly)

fig.keep: (‘high’; character) how plots in chunks should be kept; it takes five possible character values or a numeric vector (see the end of this section for an example)

  • high: only keep high-level plots (merge low-level changes into high-level plots);

  • none: discard all plots;

  • all: keep all plots (low-level plot changes may produce new plots)

  • first: only keep the first plot

  • last: only keep the last plot

if set to a numeric vector: interpret value as index of (low-level) plots to keep



190
191
192
# File 'lib/gknit/knitr_engine.rb', line 190

def fig__keep
  @fig__keep
end

#fig__lpObject (readonly)

Returns the value of attribute fig__lp.



315
316
317
# File 'lib/gknit/knitr_engine.rb', line 315

def fig__lp
  @fig__lp
end

#fig__ncolObject (readonly)

fig.ncol: (NULL; integer) the number of columns of subfigures; see here for examples (note that fig.ncol and fig.sep only work for LaTeX output)



329
330
331
# File 'lib/gknit/knitr_engine.rb', line 329

def fig__ncol
  @fig__ncol
end

#fig__pathObject (readonly)

fig.path: (‘figure/’; character) prefix to be used for figure filenames (fig.path and chunk labels are concatenated to make filenames); it may contain a directory like figure/prefix- (will be created if it does not exist); this path is relative to the current working directory; if the prefix ends in a trailing slash, e.g. output/figures/, figures will be saved in the specified directory without any changes to filename prefix, thus providing a relative filepath alternative to the package-level option base.dir



178
179
180
# File 'lib/gknit/knitr_engine.rb', line 178

def fig__path
  @fig__path
end

#fig__posObject (readonly)

fig.pos: (”; character) a character string for the figure position arrangement to be used in beginfigure



319
320
321
# File 'lib/gknit/knitr_engine.rb', line 319

def fig__pos
  @fig__pos
end

#fig__processObject (readonly)

fig.process: (NULL) a function to post-process a figure file; it should take a filename, and return a character string as the new source of the figure to be inserted in the output



341
342
343
# File 'lib/gknit/knitr_engine.rb', line 341

def fig__process
  @fig__process
end

#fig__retinaObject (readonly)

fig.retina: (1; numeric) this option only applies to HTML output; for Retina displays, setting this option to a ratio (usually 2) will change the chunk option dpi to dpi * fig.retina, and out.width to fig.width * dpi / fig.retina internally; for example, the physical size of an image is doubled and its display size is halved when fig.retina = 2



278
279
280
# File 'lib/gknit/knitr_engine.rb', line 278

def fig__retina
  @fig__retina
end

#fig__scapObject (readonly)

fig.scap: (NULL; character) short caption; if NULL, all the words before . or ; or : will be used as a short caption; if NA, it will be ignored



309
310
311
# File 'lib/gknit/knitr_engine.rb', line 309

def fig__scap
  @fig__scap
end

#fig__sepObject (readonly)

fig.sep: (NULL; character) a character vector of separators to be inserted among subfigures; when fig.ncol is specified, fig.sep defaults to a character vector of which every N-th element is newline (where N is the number of columns), e.g., fig.ncol = 2 means fig.sep = c(”, ”, ‘\newline’, ”, ”, ‘\newline’, ”, …)



336
337
338
# File 'lib/gknit/knitr_engine.rb', line 336

def fig__sep
  @fig__sep
end

#fig__showObject (readonly)

fig.show: (‘asis’; character) how to show/arrange the plots; four possible values are

  • asis: show plots exactly in places where they were generated

    (as if the code were run in an R terminal);
    
  • hold: hold all plots and output them in the very end of a code chunk;

  • animate: wrap all plots into an animation if there are mutiple plots in a chunk;

  • hide: generate plot files but hide them in the output document



199
200
201
# File 'lib/gknit/knitr_engine.rb', line 199

def fig__show
  @fig__show
end

#fig__showtextObject (readonly)

fig.showtext: (NULL) if TRUE, call showtext::showtext.begin() before drawing plots; see the documentation of the showtext package for details



345
346
347
# File 'lib/gknit/knitr_engine.rb', line 345

def fig__showtext
  @fig__showtext
end

#fig__subcapObject (readonly)

fig.subcap: (NULL) captions for subfigures; when there are multiple plots in a chunk, and neither fig.subcap nor fig.cap is NULL, subfloat{} will be used for individual plots (you need to add usepackagesubfig in the preamble); see 067-graphics-options.Rnw for an example



325
326
327
# File 'lib/gknit/knitr_engine.rb', line 325

def fig__subcap
  @fig__subcap
end

#fig__widthObject (readonly)

fig.width, fig.height: (both are 7; numeric) width and height of the plot, to be used in the graphics device (in inches) and have to be numeric



240
241
242
# File 'lib/gknit/knitr_engine.rb', line 240

def fig__width
  @fig__width
end

#highlightObject (readonly)

highlight: (TRUE; logical) whether to highlight the source code (it is FALSE by default if the output is Sweave or listings)



148
149
150
# File 'lib/gknit/knitr_engine.rb', line 148

def highlight
  @highlight
end

#includeObject (readonly)

include: (TRUE; logical) whether to include the chunk output in the final output document; if include=FALSE, nothing will be written into the output document, but the code is still evaluated and plot files are generated if there are any plots in the chunk, so you can manually insert figures; note this is the only chunk option that is not cached, i.e., changing it will not invalidate the cache



95
96
97
# File 'lib/gknit/knitr_engine.rb', line 95

def include
  @include
end

#keepObject (readonly)

Returns the value of attribute keep.



356
357
358
# File 'lib/gknit/knitr_engine.rb', line 356

def keep
  @keep
end

#labelObject (readonly)

fig.lp: (‘fig:’; character) label prefix for the figure label to be used in label{}; the actual label is made by concatenating this prefix and the chunk label, e.g. the figure label for <<foo-plot>>= will be fig:foo-plot by default



314
315
316
# File 'lib/gknit/knitr_engine.rb', line 314

def label
  @label
end

#messageObject (readonly)

message: (TRUE; logical) whether to preserve messages emitted by message() (similar to warning)



81
82
83
# File 'lib/gknit/knitr_engine.rb', line 81

def message
  @message
end

#optionsObject (readonly)

Returns the value of attribute options.



34
35
36
# File 'lib/gknit/knitr_engine.rb', line 34

def options
  @options
end

#out__extraObject (readonly)

out.extra: (NULL; character) extra options for figures, e.g. out.extra=‘angle=90’ in LaTeX output will rotate the figure by 90 degrees; it can be an arbitrary string, e.g. you can write multiple figure options in this option; it also applies to HTML images (extra options will be written into the <img /> tag, e.g. out.extra=‘style=“display:block;”’)



271
272
273
# File 'lib/gknit/knitr_engine.rb', line 271

def out__extra
  @out__extra
end

#out__heightObject (readonly)

Returns the value of attribute out__height.



264
265
266
# File 'lib/gknit/knitr_engine.rb', line 264

def out__height
  @out__height
end

#out__widthObject (readonly)

out.width, out.height: (NULL; character) width and height of the plot in the final output file (can be different with its real fig.width and fig.height, i.e. plots can be scaled in the output document); depending on the output format, these two options can take flexible values, e.g. for LaTeX output, they can be .8\linewidth, 3in or 8cm and for HTML, they may be 300px (do not have to be in inches like fig.width and fig.height; backslashes must be escaped as \); for LaTeX output, the default value for out.width will be changed to \maxwidth which is defined here out.width can also be a percentage, e.g. ‘40%’ will be translated to 0.4linewidth when the output format is LaTeX



263
264
265
# File 'lib/gknit/knitr_engine.rb', line 263

def out__width
  @out__width
end

#promptObject (readonly)

prompt: (FALSE; logical) whether to add the prompt characters in the R code (see prompt and continue in ?base::options; note that adding prompts can make it difficult for readers to copy R code from the output, so prompt=FALSE may be a better choice

this option may not work well when the chunk option engine is not R (#1274)


138
139
140
# File 'lib/gknit/knitr_engine.rb', line 138

def prompt
  @prompt
end

#renderObject (readonly)

render: (knitr::knit_print; function(x, options, …)) the function which formats the result of the chunk for the final output format. The function is given the chunk result as first argument and the list of chunk options as a named argument options. If the function contains further arguments which match names of chunk options, they are filled with the respective values. The function is expected to return one string which is then rendered appropriately for the current output format. For more information, invoke the help about custom chunk rendering: Invoke in R: vignette(‘knit_print’, package = ‘knitr’) and ?knitr::knit_print.



110
111
112
# File 'lib/gknit/knitr_engine.rb', line 110

def render
  @render
end

#resize__heightObject (readonly)

Returns the value of attribute resize__height.



287
288
289
# File 'lib/gknit/knitr_engine.rb', line 287

def resize__height
  @resize__height
end

#resize__widthObject (readonly)

resize.width, resize.height: (NULL; character) the width and height to be used in resizebox{}{} in LaTeX; these two options are not needed unless you want to resize tikz graphics because there is no natural way to do it; however, according to tikzDevice authors, tikz graphics is not meant to be resized to maintain consistency in style with other texts in LaTeX; if only one of them is NULL, ! will be used (read the documentation of graphicx if you do not understand this)



286
287
288
# File 'lib/gknit/knitr_engine.rb', line 286

def resize__width
  @resize__width
end

#resultsObject (readonly)

results: (‘markup’; character) takes these possible values markup: mark up the results using the output hook, e.g. put results in a

special LaTeX environment

asis: output as-is, i.e., write raw results from R into the output document hold: hold all the output pieces and push them to the end of a chunk hide (or FALSE): hide results; this option only applies to normal R

output (not warnings, messages or errors)


58
59
60
# File 'lib/gknit/knitr_engine.rb', line 58

def results
  @results
end

#sanitizeObject (readonly)

sanitize: (FALSE; character) whether to sanitize tikz graphics (escape special LaTeX characters); see documentation in the tikzDevice package



354
355
356
# File 'lib/gknit/knitr_engine.rb', line 354

def sanitize
  @sanitize
end

#sizeObject (readonly)

size: (‘normalsize’; character) font size for the default LaTeX output (see ?highlight in the highlight package for a list of possible values)



152
153
154
# File 'lib/gknit/knitr_engine.rb', line 152

def size
  @size
end

#splitObject (readonly)

split: (FALSE; logical) whether to split the output from R into separate files and include them into LaTeX by input{} or HTML by <iframe></iframe>; this option only works for .Rnw, .Rtex, and .Rhtml documents (it does not work for R Markdown)



87
88
89
# File 'lib/gknit/knitr_engine.rb', line 87

def split
  @split
end

#strip__whiteObject (readonly)

strip.white: (TRUE; logical) whether to remove the white lines in the beginning or end of a source chunk in the output



99
100
101
# File 'lib/gknit/knitr_engine.rb', line 99

def strip__white
  @strip__white
end

#tidyObject (readonly)

tidy: (FALSE) whether to reformat the R code; other possible values are:

* TRUE (equivalent to 'formatR'): use formatR::tidy_source() to reformat the code;
* 'styler': use styler::style_text() to reformat the code;
* a custom function of the form function(code, ...) {} to return the reformatted code;
* if reformatting failed, the original R code will not be changed (with a warning)


125
126
127
# File 'lib/gknit/knitr_engine.rb', line 125

def tidy
  @tidy
end

#tidy__optsObject (readonly)

tidy.opts: (NULL; list) a list of options to be passed to the function determined by the tidy option, e.g., tidy.opts = list(blank = FALSE, width.cutoff = 60) for tidy = ‘formatR’ to remove blank lines and set the approximate line width to be 60



131
132
133
# File 'lib/gknit/knitr_engine.rb', line 131

def tidy__opts
  @tidy__opts
end

#warningObject (readonly)

warning: (TRUE; logical) whether to preserve warnings (produced by warning()) in the output like we run R code in a terminal (if FALSE, all warnings will be printed in the console instead of the output document); it can also take numeric values as indices to select a subset of warnings to include in the output



70
71
72
# File 'lib/gknit/knitr_engine.rb', line 70

def warning
  @warning
end

Class Method Details

.device(dev_type, filename = nil, *args, width: 480, height: 480, units: "px", res: 72, pointsize: 12, bg: "white") ⇒ Object



Parameters:

  • dev_type (String)

    name of the device type to open

  • filename (String) (defaults to: nil)

    filename to store the image. By default nil for the awt device

  • args (Array)

    other parameters to be passed to device. Right now, there are no other parameters that should be passed to the available devices. Might be needed when more devices are available

  • width (Numeric) (defaults to: 480)

    width of the figure, by default 480

  • height (Numeric) (defaults to: 480)

    hegiht of the figure, by default 480

  • units (String) (defaults to: "px")

    string with units definition, by default ‘px’. Could be ‘in’, ‘cm’

  • res (Numeric) (defaults to: 72)

    resolution in dpi, if not provided set to 72

  • pointsize (Numeric) (defaults to: 12)
  • bg (String) (defaults to: "white")


544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/gknit/knitr_engine.rb', line 544

def self.device(dev_type, filename = nil, *args, width: 480, height: 480,
                units: "px", res: 72, pointsize: 12, bg: "white")

  case dev_type
      
  when "awt"
  when "svg"
    R.svg(filename)
  when "png", "pdf"
    R.png(filename, width, height, units, pointsize, bg, res, *args)
  when "jpg", "jpeg"
    R.jpeg(filename, width, height, units, pointsize, bg, res, *args)
  when "bmp" 
    R.bmp(filename, width, height, units, pointsize, bg, res, *args)
  else
    raise "Invalid device type #{device}"
  end
  
end

Instance Method Details

#add(spec) ⇒ Object


Adds the new knitr engine to the list of engines


Parameters:

  • spec (Hash)

    hash with only one pair containing the machine key and the engine function



602
603
604
# File 'lib/gknit/knitr_engine.rb', line 602

def add(spec)
  (~:knit_engines).set.call(spec)
end

#add_hook(spec) ⇒ Object





610
611
612
# File 'lib/gknit/knitr_engine.rb', line 610

def add_hook(spec)

end

#capture_plotObject


Captures a plot by calling evaluate::plot_snapshot, which has the latest plotted graphics.




569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/gknit/knitr_engine.rb', line 569

def capture_plot

  # gets a plot snapshot.  Uses function plot_snapshot from package 'evaluate'
  plot = R.evaluate_plot_snapshot

  if (!(plot.is__null >> 0))
    # create directory for the graphics files if does not already exists
    # unless (R.dir__exists(@fig__path) >> 0)
    unless File.directory?(@fig__path)
      FileUtils.mkdir_p(@fig__path)
    end

    @options.dev.each do |dev_type|
      KnitrEngine.device(dev_type >> 0, @filename,
                         width: @options.fig__width,
                         height: @options.fig__height, units: units)
      R.print(plot)
      R.dev__off
      return plot
    end
    
  end

  false

end

#fig_keepObject


Process the fig.keep chunk option


Parameters:

  • keep (String/Numeric)

    a string or a number. If it is a string then it should be one of the following:

    • high: only keep high-level plots (merge low-level changes into high-level plots);

    • none: discard all plots;

    • all: keep all plots (low-level plot changes may produce new plots)

    • first: only keep the first plot

    • last: only keep the last plot

    if set to a numeric vector: interpret value as index of (low-level) plots to keep In this case, set variable @keep to “index” and variable @keep_ind as the numeric index.



422
423
424
425
426
427
428
429
430
431
# File 'lib/gknit/knitr_engine.rb', line 422

def fig_keep
  @keep = @options.fig__keep
  @keep_idx = nil
  
  if (@keep.is__numeric >> 0)
    @keep_idx = @keep
    @keep = "index"
  end
  
end

#file_extObject





437
438
439
440
441
442
443
# File 'lib/gknit/knitr_engine.rb', line 437

def file_ext
  # guess plot file type if it is NULL
  if (((@keep != 'none') >> 0) && (@options.fig__ext.is__null >> 0))
    @fig__ext = (R.knitr_dev2ext(@options.dev) >> 0)
  end
  
end

#process_options(options) ⇒ Object


Process the chunk options




449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
# File 'lib/gknit/knitr_engine.rb', line 449

def process_options(options)

  @options = options

  # Chunk options
  @label = (options['label'] >> 0)
  
  # Text results
  @eval = options['eval'] 
  @echo = (options['echo'] >> 0)
  @results = options['results'] 
  @collapse = options['collapse'] 
  @warning = options['warning'] 
  @error = options['error'] 
  @message = options['message'] 
  @split = options['split'] 
  @include = options['include'] 
  @strip__white = options['strip.white'] 
  # @render = options['render'] # a function
  @class__output = options['class.output'] 
  
  # Code Decoration
  # @tidy = options['tidy'] 
  # @tidy__opts = options['tidy.opts']
  @prompt = options['prompt']  
  @comment = options['comment'] 
  @highlight = options['highlight'] 
  @size = options['size'] 
  @background = options['background'] 
  @class__source = options['class_source'] 
  
  # Plots
  @fig__path = (options['fig.path'] >> 0)
  # @fig__keep = options['fig.keep'] # can be a vector
  @fig__show = options['fig.show'] 
  @dev = options['dev'] 
  # @dev__args = options['dev.args'] # can be a vector
  @fig__ext = (options['fig.ext'] >> 0)
  @dpi = options['dpi'] 
  @fig__width = options['fig.width'] 
  @fig__height = options['fig.height'] 
  @fig__asp = options['fig.asp'] 
  # @fig__dim = options['fig.dim']  # vector with two elements
  @out__width = options['out.width'] 
  @out__height = options['out.height'] 
  @out__extra = options['out.extra'] 
  @fig__retina = options['fig.retina'] 
  @resize__width = options['resize.width'] 
  @resize__height = options['resize.height'] 
  @fig__align = options['fig.align'] 
  @fig__env = options['fig.env'] 
  @fig__cap = options['fig.cap'] 
  @fig__scap = options['fig.scap'] 
  @fig__lp = options['fig.lp'] 
  @fig__pos = options['fig.pos'] 
  @fig__subcap = options['fig.subcap'] 
  @fig__ncol = options['fig.ncol'] 
  # @fig__sep = options['fig.sep'] # a vector
  @fig__process = options['fig.process'] 
  @fig__showtext = options['fig.showtext'] 
  @external = options['external'] 
  @sanitize = options['sanitize'] 

  # verifies if figures should be kept
  fig_keep

  # if figures are to be kept, take or guess the file extension
  file_ext
  
  # make final filename
  @filename = "#{@fig__path}#{@label}.#{@fig__ext}"
  @options["filename"] = "."

  # create temporary file for storing plots
  # TODO: should remove this directory afterwards
  @tmp_fig = (R.tempfile() >> 0)
  
end

#unitsObject





403
404
405
406
# File 'lib/gknit/knitr_engine.rb', line 403

def units
  opt_units = (@options[["units"]])
  (opt_units.is__null >> 0) ? "in" : opt_units
end