Produces the LaTeX code and compiles to a PDF file from the edsurveyTable
results.
Usage
edsurveyTable2pdf(
data,
formula,
caption = NULL,
filename = "",
toCSV = "",
returnMeans = TRUE,
estDigits = 2,
seDigits = 3
)
Arguments
- data
the result of a call to
edsurveyTable
- formula
a formula of the form
LHS ~ RHS
to cast theedsurveyTable
results from long format to wide format. This formula takes the formLHS ~ RHS
(e.g.,var1 + var2 ~ var3
). The order of the entries in the formula is essential.- caption
character vector of length one or two containing the table's caption or title. If the length is two, the second item is the “short caption” used when LaTeX generates a
List of Tables
. Set toNULL
to suppress the caption. Default value isNULL
.- filename
a character string containing filenames and paths. By default (
filename = ""
), table will be saved in the working directory (getwd()
). Usefilename = "CONSOLE"
to print LaTeX code in R console without generating a PDF file.- toCSV
a character string containing filenames and paths of .csv table output.
""
indicates no .csv output.toCSV
is independent tofilename
, so both a csv file and PDF file would be generated if bothfilename
andtoCSV
were specified.- returnMeans
a logical value set to
TRUE
(the default) to generate a PDF with theMEAN
andSE(MEAN)
. It is set toFALSE
to generate a PDF with thePCT
andSE(PCT)
. See Value inedsurveyTable
.- estDigits
an integer indicating the number of decimal places to be used for estimates. Negative values are allowed. See Details.
- seDigits
an integer indicating the number of decimal places to be used for standard errors. Negative values are allowed.
Details
Rounding to a negative number of digits means rounding to a power of 10,
so, for example, estDigits = -2
rounds estimates to the nearest hundred.
Note
For more details, see the vignette titled
Producing LaTeX
Tables From edsurveyTable
Results With edsurveyTable2pdf
.
Examples
if (FALSE) { # \dontrun{
# read in the example data (generated, not real student data)
sdf <- readNAEP(path=system.file("extdata/data", "M36NT2PM.dat", package="NAEPprimer"))
# create a table with composite scores by dsex and b017451
est1 <- edsurveyTable(formula=composite ~ dsex + b017451, data=sdf)
# create a table with csv output
edsurveyTable2pdf(data=est1,
formula=b017451~dsex,
toCSV="C:/example table.csv",
filename="C:/example table.pdf",
returnMeans=FALSE)
# create a pdf file using the default subject scale or subscale
# and keep two digits for estimates and three digits for SE after decimal point
edsurveyTable2pdf(data=est1, formula=b017451~dsex,
returnMeans=TRUE, estDigits=2, seDigits=3)
# create a pdf file using the percentage of students at the
# aggregation level specified by \code{pctAggregationLevel}
# output will be saved as "C:/example table.pdf"
edsurveyTable2pdf(data=est1,
formula=b017451~dsex,
filename="C:/example table.pdf",
returnMeans=FALSE)
} # }