BarPieImage
Example List of Images
Description
The data.frame BarPieImage contains three images
of plots created in Open Source R.
Each image shows a barchart and a piechart of the same data.
The data.frame BarPieData contains data displayed in the
images in BarPieImage.
Usage
data(BarPieImage)
data(BarPieData)
Format
Details
The code in the example shows how BarPieImage was created from
BarPieData.
Examples
## Not run:
# This code needs to be run in Open Source R to create the PNG images.
BarPieData <- read.csv("BarPieData.csv")
save(BarPieData, file="BarPieData.rda")
#
png(filename="bar_vs_pie_chart_%01d.png", width=350, height=300)
par(mfrow=c(1,2))
par(mar=c(2.1, 2.1, 3, 0))
#
nchart <- length(unique(BarPieData$Chart))
for(i in seq.int(nchart)) {
datasub <- with(BarPieData, BarPieData[Chart == i, ])
barplot(datasub$Value, names=datasub$Group, col=2:6,
main=paste("Bar Plot", i))
pie(datasub$Value, labels = datasub$Group, col=2:6,
main=paste("Pie Chart", i))
}
#
dev.off()
#
BarPieImage <- data.frame(BarVsPie = seq.int(nchart), stringsAsFactors = FALSE)
glist <- list()
for(i in seq.int(nchart)) {
pngFile <- paste0("bar_vs_pie_chart_", i, ".png")
glist[[i]] <- readBin(pngFile, what="raw", n=file.info(pngFile)$size)
}
names(glist) <- paste0("Chart_", seq.int(nchart))
BarPieImage[["BarVsPie"]] <- glist
save(BarPieImage, file="BarPieImage.rda")
## End(Not run)