rtlu                 package:r2lUniv                 R Documentation

~ _F_u_n_c_t_i_o_n: _R _t_o _L_a_T_e_X, _U_n_i_v_a_r_i_a_t_e _a_n_a_l_y_s_i_s ~

_D_e_s_c_r_i_p_t_i_o_n:

     'rtlu' performs some basic analyses, then generates a code to be
     included in a LaTeX document to print the analyses in a (so nice!)
     LaTeX way.

_U_s_a_g_e:

       rtlu(data,fileOutput="",textBefore="",textAfter="",graphDir="graphUniv",graphName="V",type="png",limDiscrete=10)

_A_r_g_u_m_e_n_t_s:

    data: '[data.frame]' or a '[vector]' : containt the data to
          analyse.

fileOutput: '[character]'; name of the output file in which the LaTeX
          summary will be saved. If empty, the LaTeX code is printed on
          screen.

textBefore: '[character] or [vector(character)]' : before printing a
          variable analysis, 'rtlu' can write a text. If 'rtlu' is
          apply on a single variable, 'textBefore' should be of lenght
          1. If 'rtlu' is apply on a data.frame, 'textBefore' can have
          the lenght of the data.frame (this let the user to write a
          specific introduction for each variable), or can be of length
          1. In this case, it is print before each variable analysis.
          See examples for detail.

textAfter: '[character] or [vector(character)]' : after printing a
          variable analysis, 'rtlu' can write a text. If 'rtlu' is
          apply on a single variable, 'textAfter' should be of lenght
          1. If 'rtlu' is apply on a 'data.frame', 'textAfter' can have
          the lenght of the data.frame (this let the user to write a
          specific conclusion for each variable), or can be of length
          1. In this case, it is print after each variable analysis.
          See examples for detail.

graphDir: '[character]' : directory used to save the graph generated by
          the analyses.

graphName: '[character]' or '[vector(character)]' : prefix of the
          graphs' names. If empty, the graphs' name are 'V1' to 'V
          length(data.frame)'

    type: '[character]' : type of plot used to export the graphics. Can
          be Windows metafile, PNG, JPEG, BMP (Windows bitmap format),
          TIFF, PostScript or PDF. See savePlot for details.

limDiscrete: 'rtlu' distinghues two kind of 'numeric' : 'discrete' are
          'numeric' variable with only few modalities,  'continuous'
          are 'numeric' variable with many modalities. The limit
          between 'few' and 'many' can be fixed by the user through the
          argument 'limDiscrete'. By setting 'limDiscrete' to 5, the
          user will ask 'rtlu' to consider all the 'numeric' variable
          with more than 5 modalities as 'continuous' and all the
          variable with less than 5 modalities as 'discrete'.

          The default value for 'limDiscrete' is 10.

_D_e_t_a_i_l_s:

     'rtlu' performs some basic analyses, then generates a code to be
     included in a LaTeX document to print the analyses in a (so nice!)
     LaTeX way.

     'rtlu' performs the analyses automatically according to the 'data'
     class. It considers 4 classes. The analysis of the variable depend
     of the class:

        1.  factor, character and logical: Frequency ; Graph: barplot

        2.  ordered: Frequency, quartile ; Graph: barplot

        3.  numeric discrete: Frequency, mean, variance, quartile ;
           Graph: boxplot and barplot

        4.  numeric continuous: Mean, variance, quartile ; Graph:
           boxplot and histogram.

     On a 'data.frame', 'rtlu' runs the analyses on every column.

_V_a_l_u_e:

     'rtlu' generates a LaTeX code and either prints it on screen or
     saves it in a file. It also generates several encapsulated
     postscript graphs, optionally in a different directory.

_C_l_a_s_s_i_c_a_l _u_s_a_g_e:

     The use of 'rtlu' 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 'rtlu(dataFrame,"fileOut.tex")'.

     See examples an application.

_R _t_o _L_a_T_e_X, _B_i_v_a_r_i_a_t_e _A_n_a_l_y_s_e_s:

     _r2lBiv_ (R to LaTeX, Bivariate Analyses) is under construction.
     Any help will be welcomed!

_A_u_t_h_o_r:

     Christophe Genolini 
      christophe.genolini@free.fr
      PSIGIAM: Paris Sud Innovation Group in Adolescent Mental Health 
      INSERM U669 / Maison de Solenn / Paris

_E_n_g_l_i_s_h _c_o_r_r_e_c_t_i_o_n:

     Jean-Marc Chamot 
      jchamot@u-paris10.fr
      Laboratoire "Sport & Culture" / "Sports & Culture" Laboratory 
      University of Paris 10 / Nanterre

_V_a_r_i_a_b_l_e _1 _t_o _3:

     Jean-Marc Chamot 
      jchamot@u-paris10.fr
      Laboratoire "Sport & Culture" / "Sports & Culture" Laboratory 
      University of Paris 10 / Nanterre

_S_u_r_v_e_y:

     Jean-Marc Chamot 
      jchamot@u-paris10.fr
      Laboratoire "Sport & Culture" / "Sports & Culture" Laboratory 
      University of Paris 10 / Nanterre

_U_n_i_v_a_r_i_a_t_e _a_n_a_l_y_s_i_s:

     Jean-Marc Chamot 
      jchamot@u-paris10.fr
      Laboratoire "Sport & Culture" / "Sports & Culture" Laboratory 
      University of Paris 10 / Nanterre

_M_o_r_e _i_n_f_o_r_m_a_t_i_o_n?:

     Jean-Marc Chamot 
      jchamot@u-paris10.fr
      Laboratoire "Sport & Culture" / "Sports & Culture" Laboratory 
      University of Paris 10 / Nanterre

_R_e_f_e_r_e_n_c_e_s:

     LaTeX web site <URL: http://www.latex-project.org/>
      Data are available on line: <URL:
     http://christophe.genolini.free.fr/EPO/EPO2007-Fraude.php>

_S_e_e _A_l_s_o:

     'r2lUniv-package', 'rtluMainFile', 'examCheating', 'Sweave',
     'latex'

_E_x_a_m_p_l_e_s:

      # # # # # # # # # # # # # # # # # # #
     #   R to LaTeX, Univariate Analyses   #
      #             Examples              #
       #       rtlu single variable      #
        # # # # # # # # # # # # # # # # #

     ########################
     ###### Step 1: Create the data
     par(ask=FALSE)
     V1 <- factor(LETTERS[floor(runif(50,1,4))])
     V2 <- rnorm(50,1,1)<0
     V3 <- ordered(LETTERS[floor(runif(50,1,4))])

     ########################
     ###### Step 2: ordering variable
     # nothing to do

     ########################
     ###### Step 3: running r2lu

     ### The following code will create some files.
     ### So we first move in a directories.

     if(!file.exists("exampleSingle")){dir.create("exampleSingle")}else{}
     setwd("exampleSingle")
     try(rtlu(V1,fileOutput="first.tex",textBefore="\section{Variable 1 to 3}",graphName="V1"))
     try(rtlu(V2,fileOut="second.tex",graphName="V2"))
     try(rtlu(V3,fileOut="third.tex",textBefore="This is variable 3",graphDir="P"))
     rtluMainFile(text="\input{first.tex}\n\input{second.tex}\n\input{third.tex}")
     setwd("..")



      # # # # # # # # # # # # # # # # # # #
     #   R to LaTeX, Univariate Analyses   #
      #          Real examples            #
       #        rtlu 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 r2lu

     ### The following code will create some files.
     ### So we first move in a directories.

     if(!file.exists("exampleReal")){dir.create("exampleReal")}else{}
     setwd("exampleReal")

     ### Then we prepare the textBefore, for transition between variable

     textBefore <- paste("\subsection{",names(examCheating)[c(2:5,18:20)],"}",sep="")

     text <- "\tableofcontents
     \section{Survey}
       \begin{enumerate}
         \item What is your age?
         \item What is your gender?
         \item What is your level?
         \item What is your field?
         \item Did you cheat at Bac?
         \item Did you cheat high scool?
         \item Cheating score
       \end{enumerate}
     \section{Univariate analysis}
       \input{ExamCheat-univ.tex}

     \section{More information?}
     For a detailled analysis, see
     http://christophe.genolini.free.fr/EPO/2007 Fraude/EPO2007-Fraude-Rapport.pdf"

     ### We can run r2lu
     try(rtlu(examCheating[,c(2:5,18:20)],fileOutput="ExamCheat-univ.tex",textBefore=textBefore))
     rtluMainFile("ExamCheat-main.tex",text=text)
     setwd("..")

     ### Then compile main.tex twice. It is ready !

