R Markdown to HTML

This is an example of an Rmarkdown file. Run the irisRMarkdownHtml.Rmd file through rmarkdown::render to create file irisRMarkdownHtml.html file.

Table \ref{irisBW5num} was generated by the \verb:``r: chunk and included in thisRmd` file.

The file was run by rmarkdown::render("irisRMarkdownHtml.Rmd", output_file="irisRMarkdownHtml.html") system(paste("open", "irisRMarkdownHtml.html"))

library(microplot)
library(lattice)
library(htmlTable)

iris.melt <- reshape2::melt(iris, id="Species")
irisBW <- bwplot( ~ value | Species * variable, data=iris.melt)

## twelve individual boxplots without axes
irisBW.update <-
update(irisBW,
       xlab=NULL,
       par.settings=list(
         layout.heights=layoutHeightsCollapse(),
         layout.widths=layoutWidthsCollapse(),
         axis.line=list(col="transparent")),
       layout=c(1,1)
       )


png("irisBW%03d.png",
    height=30, width=200)  ## pixels
irisBW.update
suppress <- dev.off()

graphnames <- paste0("irisBW", sprintf("%03i", 1:12), ".png")

graphicsnames <- t(matrix(as.htmlimg(graphnames),
                          nrow=3, ncol=4,
                          dimnames=dimnames(irisBW)))

## Each of the twelve Species*Measurement with its five number summary
iris2 <- array(iris.melt$value, ## $
               dim=c(50, 3, 4),
               dimnames=list(NULL,
                 levels(iris.melt$Species),
                 levels(iris.melt$variable)))
iris2.fivenum <- apply(iris2, 2:3, fivenum)
dimnames(iris2.fivenum)[[1]] <- c("min", "Q1", "med", "Q3", "max")

## Species and Measurement in separate columns
BW5num <-
rbind(
data.frame(format(t(iris2.fivenum[,1,]), nsmall=2), "Box Plots"=graphicsnames[,1], check.names=FALSE),
data.frame(format(t(iris2.fivenum[,2,]), nsmall=2), "Box Plots"=graphicsnames[,2], check.names=FALSE),
data.frame(format(t(iris2.fivenum[,3,]), nsmall=2), "Box Plots"=graphicsnames[,3], check.names=FALSE))
BW5num$Measurement=levels(iris.melt$variable)
BW5num <- BW5num[, c(7,1:6)]

htmlTable(BW5num,
          rnames=rep(" ", 12),
          rowlabel="Species",
          rgroup=levels(iris.melt$Species),
          n.rgroup=c(4,4,4),
          cgroup=c("", "Five Number Summary", ""),
          align="llrrrrrc",
          n.cgroup=c(1, 5, 1),
          caption="Five Number Summary and Box Plots for each Species and Measurement.",
          label="irisBW5num")


Try the microplot package in your browser

Any scripts or data that you put into this service are public.

microplot documentation built on Nov. 29, 2020, 1:07 a.m.