Learn R Programming

AlphaPart (version 0.7.0)

savePlot: savePlot.plotSummaryAlphaPart.R

Description

Save plot objects on the disk for permanent storage. Function savePlot from the grDevices package works for current page on graphical device. This is an attempt to make this function generic so that one can define savePlot methods for particular needs.

Usage

savePlot(x, filename = paste("Rplot", type, sep = "."), type = c("pdf",
  "png", "jpeg", "tiff", "bmp"), device = dev.cur(), ...)

# S3 method for plotSummaryAlphaPart savePlot(x, filename = paste("Rplot", type, sep = "."), type = c("pdf", "png", "jpeg", "tiff", "bmp"), device = dev.cur(), pre.hook = NULL, traitsAsDir = FALSE, ...)

Arguments

x

Object on which to chose savePLot method.

filename

Character, filename to save to.

type

Character, file/device type.

device

Device, the device to save from. TODO

...

Arguments passed to type specific methods, say width and height for type="pdf" etc.

pre.hook

Function, call some code before calling print method for plots (see examples).

traitsAsDir

Logical, should plots be saved within trait folders; the construction is file.path(dirname(file), trait, basename(file)). folders are created if they do not exist.

Value

Beside the side effect of saving plots to disk, filenames are printed on screen during the process and at the end invisibly returned.

Methods (by class)

  • plotSummaryAlphaPart: Save plot objects of class plotSummaryAlphaPart on the disk for permanent storage.

See Also

savePlot help page on the default savePlot method in the grDevices package; savePlot.plotSummaryAlphaPart help page on the method for the objects of plotSummaryAlphaPart class; and plot.summaryAlphaPart for ploting results of summaryAlphaPart object.

Examples

Run this code
# NOT RUN {
## Load an example data
data("AlphaPart.ped")

## --- Partition additive genetic values by loc ---
(res <- AlphaPart(x=AlphaPart.ped, colPath="loc", colAGV=c("agv1", "agv2")))

## Summarize whole population
(ret <- summary(res))

## Summarize population by generation (=trend)
(ret <- summary(res, by="gen"))

## Summarize population by generation (=trend) and location 1
(ret <- summary(res, by="loc.gen"))

## Summarize population by generation (=trend) but only for location 1
(ret <- summary(res, by="gen", subset=res[[1]]$loc == 1))

## --- Partition additive genetic values by loc and sex ---

AlphaPart.ped$loc.sex <- with(AlphaPart.ped, paste(loc, sex, sep="-"))
(res <- AlphaPart(x=AlphaPart.ped, colPath="loc.sex", colAGV=c("agv1", "agv2")))

## Summarize population by generation (=trend)
(ret <- summary(res, by="gen"))

## Summarize population by generation (=trend) and location 1
(ret <- summary(res, by="loc.gen"))

## Summarize population by generation (=trend) but only for location 1
(ret <- summary(res, by="gen", subset=res[[1]]$loc == 1))
# }

Run the code above in your browser using DataLab