Last chance! 50% off unlimited learning
Sale ends in
r2htmlBiv
(or r2hb
in short) performs some bivariate analyses, then generates code to be
included in a HTML document in order to print out the analyses on a Web page.r2hb(formula,fileOut="",textBefore="",textAfter="",graphDir="graphBiv",graphName="V",type="png",displayStyle=7,limDiscreteY=10,limDiscreteX=10)
r2htmlBiv(formula,fileOut="",textBefore="",textAfter="",graphDir="graphBiv",graphName="V",type="png",displayStyle=7,limDiscreteY=10,limDiscreteX=10)
[variable~variable]
or [variable~data.frame]
: contains the
data to analyse. In all the following, the left part will be called
Y
, the right part will be X
.[character]
name of the output file in which
the HTML summary will be saved. If empty, the HTML code is printed on screen.[character] or [vector(character)]
: before
printing a variable analysis, r2hb
can write a
text. If X
is a single variable,
textBefore
should be of length 1. If X
is a d
[character]
or [vector(character)]
: same
as textBefore
but the text is printed after the variable
analysis. See textBefore
and examples for details.[character]
:
directory used to save the graphs generated by the analyses.[character]
or [vector(character)]
:
prefix for the graph names. If empty, the graph names are
V1
to V'length(data.frame)'
[character]
: type of plotting device used to export the
graphics. Can be Windows metafile, PNG, JPEG, BMP (Windows bitmap format), TIFF,
PostScript or PDF.[numeric]
or [vector(numeric)]
:
r2hb
proposes two different ways of displaying the results.
The first one is compact, it displays all the results on two lines. If the
number of modalities of X
[numeric]
: r2hb
distinguishes two
kinds of numeric
variables:
discrete
designates numeric
variables with only a few
modalities, continuous
designates nume
[numeric]
or [vector(numeric)]
: same
as limDiscreteY
. If X
is a data.frame
, limDiscreteX
can have the same
length as X
or can be of length 1 (and is recycr2hb
generates HTML code and either prints it on the screen, or saves it in a
file. It also generates several graphs, optionally
in a different directory.r2hb
goes through the following steps:
data.frame
).
Step 2. Optionally, set some variables as ordered
.
Step 3. Run r2hb(Y~dataFrame,"fileOut.html")
.
}
See examples of application.r2hb
performs some basic analyses, then generates
code to be included in a HTML document in order to print out the analyses in a
Web page.
r2hb
performs the analyses automatically according to the
data
class. It considers 5 classes: nominal with 2 modalities,
nominal with 3 modalities or more, ordered, discrete and
continuous (see the description of limDiscreteY
for details on
discrete and continuous).
The analysis of the variable depends on the class of Y
and
X
wich gives 25 possible combinations. We will not give a
description here, all of them are presented in the pdf file Y
is continuous andX
has
few modalities.X
, mosaic plot, scatter plot, density lines
according to the type of the variable.Y
and X
.
Y
andX
. Note that as
many tests as possible are run. For example, ifY
is nominal
andX
is ordered,X
can be considered as
a factor (khi2 and Fisher exact test) but also as a discrete variable (Wilcoxon).X
is a data.frame
, r2hb
runs the analyses on
every column.
See r2hMainFile
,
r2htmlUniv
,
r2htmlUniv-package
,
examCheating
# # # # # # # # # # # # # # # # # # #
# R to HTML, Bivariate Analyses #
# Artificial examples #
# Single variable #
# # # # # # # # # # # # # # # # #
### Create some data
V1 <- factor(LETTERS[floor(runif(50,1,4))])
V2 <- rnorm(50,1,1)<0
V3 <- ordered(LETTERS[floor(runif(50,1,4))])
### Create a directory for the output
if(!file.exists("tmp/r2hbExample",recursive=TRUE)){dir.create("tmp/r2hbExample",recursive=TRUE)}else{}
setwd("tmp/r2hbExample")
### Execute r2hb
r2hb(V1~V2,fileOut="first.html",textBefore="<H2>Variables V1, V2, V3</H2>",graphName="Gr1",type="png")
r2hb(V2~V1,fileOut="second.html",graphName="Gr2",type="png")
r2hb(V3~V1,fileOut="third.html",textBefore="This is V3 vs. V1",graphDir="P",graphName="Gr3",type="png",displayStyle=2)
r2hMainFile(text="<LU>
<LI><A HREF='first.html'>First example</A></LI>
<LI><A HREF='second.html'>Second example</A></LI>
<LI><A HREF='third.html'>Third example</A></LI>
</LU>
")
setwd("..")
Run the code above in your browser using DataLab