View source: R/tabtexdescstat.r
tabtexdescstat | R Documentation |
Function to create a LaTeX file for a table of descriptive statistics of continuous variables from a dataframe.
tabtexdescstat(
data = data,
colnames = colnames,
varnames = varnames,
cap = cap,
nametab = nametab,
save.file = FALSE,
filename = "tabdescdata.tex",
eng = TRUE,
rowlab = "Variable",
decnum = 3,
font.size.tab = "normalsize",
font.type.tab = "normalfont",
variable.row = FALSE
)
data |
a dataframe containing numeric variables as columns. |
colnames |
a string having the column names of the dataframe to which the descriptive statistics will be computed. |
varnames |
a string having the name of each of the variables to be used in the LaTeX table. |
cap |
a string having the caption of the LaTeX table. |
nametab |
a string having a brief name to be used in
both the label of the table and the file name. For instance,
if "=descdata", the table can be refered in your LaTeX
document by using |
save.file |
The defauls is set to “FALSE”, if is set to
TRUE, then the option |
filename |
A string having the name of the resulting LaTeX file having the table. The default is set to "tabdescdata.tex". |
eng |
The language to be used in the output. English
is the default, meanwhile if |
rowlab |
a character with the name to be used as label for the column where the variables will be printed. The default is set to "Variables". |
decnum |
the number of decimals to be used in the output. The default is set to 3. |
font.size.tab |
The defauls is set to "normalsize". You could also try with "footnotesize". |
font.type.tab |
The defauls is set to "normalfont". |
variable.row |
A logical option specifying whether the variables are used in the rows of the output. The default is to FALSE, thus, the variables are used as the main colum of the table. |
The resulting file is a LaTeX table, that can be
added to your main LaTeX document by using \input{filename}
.
This function creates a LaTeX file having the following descriptive statistics: sample size, minimum, maximum, mean, median, SD, and coefficient of variation. If the full option is set to TRUE, the following statistics are added to the table: 25th and 75th percentiles, the interquartile range, skewness, and kurtosis.
Christian Salas-Eljatib.
Salas-Eljatib, C. 2021. Análisis de datos con el programa estadístico R: una introducción aplicada. Ediciones Universidad Mayor, Santiago, Chile. 170 p. https://eljatib.com/rlibro
df <- datana::idahohd
head(df)
##example 1
tabtexdescstat(data=df,nametab="idaho",
cap="Descriptive statistics table",
colnames=c("dbh","toth"),varnames = c("Diameter","Height"))
##example 2
tabtexdescstat(data=df,nametab="idaho",
cap="Cuadro con estadistica descriptiva",
colnames=c("dbh","toth"),varnames = c("Diametro","Altura"),
eng=FALSE)
##! Example 3: variables as columns
tabtexdescstat(data=df,nametab="idaho",
cap="Descriptive statistics table",colnames=c("dbh","toth"),
varnames = c("Diameter","Height"),variable.row=FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.