knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" ) require(stpvers)
Die Scripten dienen der Erstellung von Reports als HTML aber auch von PDF ueber knit. Zum Teil handelt es sich um modifizerte Funktionen von R2HTML, texreg und htmlTable.
Projekt()
und End()
Initialisiert ein neues Projekt und aufruf der HTML-Seite mit Hilfe von R2HTML.HTML_Start()
und HTML_End()
Wie Projekt aber ohne den ganzen Überhau von R2HTML.Output
Erstellt TabellenText
, HTML_P
und HTML_...
Schreibt HTML Text.
Hilfsfunktionen
SaveDate
Speichert Bilder in den Arbeitsfolder.fix_irgendwas
Repariert Levels und Labels und Zahlen fuer die Ausgabe.set_my_options
und get_my_options
Formatierungs-OptionenFile | Type | Parameter | which_output() -----|---------|-----------------|-------------- r | | | text r | Projekt("html") | | html r | spin | html_document | markdown_html r | spin | pdf_document | latex r | spin | word_document | docx Rmd | | html_document | markdown_html Rmd | | pdf_document | latex Rmd | | word_document | docx Rmd | | beamer | latex Rmd | | github_document | markdown_html
Initialisieren eines Projektes.
# devtools::install_github("stp4/stp25output") get_my_options()$output which_output() Projekt("md", "Beispiel Projekt", datum = date(), fig_folder = "Fig", html_folder = "Results", OutDec = NULL, contrasts = c("contr.Treatment", "contr.poly") ) get_my_options()$output which_output() set_my_options(prozent=list(digits=c(1,0), style=2)) set_lattice_ggplot() # Optionen format: HTML, Spin, Knit, Rpres oder Text APA2(.~ gruppe , hkarz, caption="Deskriptive Analyse") End()
data.frame()
get_my_options()$output which_output() dat<- data.frame( term = c("A", "B", "C", "D"), n = c(23, 14, 56, 2), m = c("4.7 (2.4)", "4.1 (2.3)", "8.9 (3.6)", NA) ) dat %>% Output("data.frame()")
matrix(c("a1","a2",3,4,5,6), nrow=2, byrow=TRUE, dimnames=list(gender=c("M", "F"), party=c( "Dem", "Ind", "Rep"))) #%>% Output("matrix()") as.table(matrix(c("a1","a2",3,4,5,6), nrow=2, byrow=TRUE, dimnames=list(gender=c("M", "F"), party=c( "Dem", "Ind", "Rep")))) %>% Output("as.table()")
Tabelle2(hkarz, tzell, lai, gruppe, APA=TRUE )
res<- Tabelle(hkarz, tzell, lai, gruppe, APA=TRUE) Output(res, add_row =c("<b>Erste Zeile</b>" = 1, "Dritte Zeile" = 3) )
get_my_options()$output which_output()
df1 <- data.frame( term = c("A", "B", "C", "D"), n = c(23, 14, 56, 2), m = c("4.7 (2.4)", "4.1 (2.3)", "8.9 (3.6)", NA) )
#+ df1 %>% Output() df1 %>% Output(output=TRUE) df1 %>% Output(output=FALSE)
df1 %>% Output()
df1 %>% Output(output="text")
df1 %>% Output(output="markdown")
Ist eine Package zum Erstellen von HTML und latex. Convert an R object to an xtable object, which can then be printed as a LaTeX or HTML table
require(xtable) data(tli) ## Demonstrate aov fm1 <- aov(tlimth ~ sex + ethnicty + grade + disadvg, data = tli) fm1.table <- xtable(fm1) Output(fm1.table)
fm2 <- lm(tlimth ~ sex*ethnicty, data = tli) fm2b <- lm(tlimth ~ ethnicty, data = tli) #Output(xtable(anova(fm2b, fm2)), output="md")
knitr::kable( df1, row.names = FALSE, format = "pandoc" )
knitr::kable( df1, row.names = FALSE, format = "markdown" )
knitr::kable( df1, row.names = FALSE, format = "pandoc" )
require(stpvers) set.seed(2) n <- 20 * 3 * 2 DF <- data.frame( n = runif(n, min = 1, max = 5), e = runif(n, min = 1, max = 5), o = runif(n, min = 1, max = 5), g = runif(n, min = 1, max = 5), a = runif(n, min = 1, max = 5), treatment = gl(3, n / 3, labels = c("UG1", "UG2", "KG"))[sample.int(n)], sex = gl(2, n / 2, labels = c("male", "female")) )
set_lattice() bwplot2(e ~ treatment, DF, groups = sex, auto.key = list(columns = 2))
set_lattice_ggplot() bwplot2(e ~ treatment, DF, groups = sex, auto.key = list(columns = 2))
set_lattice_bw() bwplot2(e ~ treatment, DF, groups = sex, auto.key = list(columns = 2)) reset_lattice()
Quelle: https://gist.github.com/benmarwick/8ad99f35d5e4caa06492
https://github.com/yihui/printr https://github.com/jalapic/simpletable https://github.com/renkun-ken/formattable
my_data <- head(iris) names(my_data) <- c(letters[1:ncol(iris)])
library("knitr") kable(my_data)
library("xtable") print(xtable(my_data), type = "html", include.rownames=FALSE, html.table.attributes=list("border='0' cellpadding='5' "))
library(xtable) print(xtable(my_data), type = 'html')
library(xtable) print(xtable(my_data), type = 'html', html.table.attributes = '')
library("pander") pandoc.table(my_data)
library("pander") pandoc.table(my_data, split.cells = 5)
pander::panderOptions('table.split.table', 350) pander::pandoc.table(my_data, style="rmarkdown")
library("ascii") print(ascii(my_data), type = 'pandoc')
library("htmlTable") htmlTable(my_data, col.rgroup = c("none", "#F7F7F7"))
library(hwriter) hwrite(my_data, border=0)
This one is the most useful, and has a nice guide to customisation here: http://www.ebi.ac.uk/~gpau/hwriter/
library(hwriter) cat( hwrite( my_data, border = 0, center = TRUE, table.frame = 'void', width = '300px', table.style = 'padding: 50px', row.names = FALSE, row.style = list('font-weight:bold') ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.