Description Usage Arguments Details Value Classical usage Author References See Also Examples
r2htmlUniv
(r2hu
in short) performs some basic analyses, then generates
code to be included in a HTML document.
1 2 | r2hu(x,fileOut="",textBefore="",textAfter="",graphDir="graphUniv",graphName="V",type="png",limDiscrete=10)
r2htmlUniv(x,fileOut="",textBefore="",textAfter="",graphDir="graphUniv",graphName="V",type="png",limDiscrete=10)
|
x |
|
fileOut |
|
textBefore |
|
textAfter |
|
graphDir |
|
graphName |
|
type |
|
limDiscrete |
The default value for |
r2hu
performs some basic analyses, then generates
code to be included in a HTML document.
r2hu
performs the analyses automatically according to the
data
class. It considers four classes. The analysis of the
variable depends on the class:
factor, character and logical: Frequency and barplot
ordered: Frequency, quartile and barplot
numeric discrete: Frequency, mean, variance, quartile, boxplot and barplot
numeric continuous: Mean, variance, quartile, boxplot and histogram.
On a data.frame
, r2hu
runs the analyses on every column.
See /library/r2lh/doc/r2lhOutput.pdf for display details.
r2hu
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.
The use of r2hu
goes through the following steps:
Step 1. | Load the data (usually, a data.frame ). |
Step 2. | Optionally, set some variables as ordered . |
Step 3. | Run r2hu(dataFrame,"fileOut.html") . |
See examples of application.
Christophe Genolini
christophe.genolini@free.fr
PSIGIAM: Paris Sud Innovation Group in Adolescent Mental Health
INSERM U669 / Maison de Solenn / Paris
Bernard Desgraupes
bernard.desgraupes@u-paris10.fr
University of Paris Ouest - Nanterre
HTML web site http://www.w3.org/TR/html/
Data are available on line: http://christophe.genolini.free.fr/EPO/EPO2007-Fraude.php
r2hMainFile
,
r2htmlBiv
,
r2latexUniv-package
,
examCheating
,
Sweave
,
latex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | # # # # # # # # # # # # # # # # # # #
# R to HTML, Univariate Analyses #
# Examples #
# r2hu 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")){dir.create("tmp")};setwd("tmp")
if(!file.exists("r2huExample")){dir.create("r2huExample")};setwd("r2huExample")
### Execute r2hu
r2hu(V1,fileOut="first.html",textBefore="<h2>Variable 1 to 3</h2>",graphName="V1")
r2hu(V2,fileOut="second.html",graphName="V2")
r2hu(V3,fileOut="third.html",textBefore="This is variable 3",graphDir="P")
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>
")
# # # # # # # # # # # # # # # # # # #
# R to HTML, Univariate Analyses #
# Real examples #
# r2hu data.frame #
# # # # # # # # # # # # # # # # #
########################
###### Step 1: Create the data
data(examCheating)
str(examCheating)
########################
###### Step 2: ordering variable
examCheating$YearOfStudy <- ordered(examCheating$YearOfStudy,levels=c("L1","L2","L3","M1","M2"))
examCheating$Bac <- ordered(examCheating$Bac,levels=c("Remedial exam","Pass","Fairly good","Good","Very good","Summa cum laude"))
for(iColumn in 8:17){
examCheating[,iColumn] <- ordered(examCheating[,iColumn],levels=c("Never","Rarely","Sometimes","Often","Always"))
}
str(examCheating)
########################
###### Step 3: running r2hu
### Preparation of textBefore, for transition between variable
textBefore <- paste("<h3>",names(examCheating)[c(2:5,18:20)],"</h3>",sep="")
text <- "
<h2>Survey</h2>
<ul>
<li> What is your age?</li>
<li> What is your gender?<li>
<li> What is your level?<li>
<li> What is your field?<li>
<li> Did you cheat at Bac?<li>
<li> Did you cheat high scool?<li>
<li> Cheating score<li>
</ul>
<h2>Univariate analysis</h2>
<OBJECT data = 'ExamCheat-univ.html' type = 'text/html'></OBJECT>
<h2>More information?</h2>
For a detailled analysis, see
http://christophe.genolini.free.fr/EPO/2007 Fraude/EPO2007-Fraude-Rapport.pdf"
### We can run r2hu
r2hu(examCheating[,c(2:5,18:20)],fileOut="ExamCheat-univ.html",textBefore=textBefore)
r2hMainFile("ExamCheat-main.html",text=text)
setwd("../..")
### Then open ExamCheat-main.html in your browser. It is ready !
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.