User:Bert Niehaus/KnitR-Example

From Wikiversity
Jump to navigation Jump to search

title: "Presentation" author: "Bert Niehaus" date: "7 Januar 2018" output: ioslides_presentation: default ---

Display R-Code in Output[edit]

In general the R-code is not echoed in the output. If you want to view the code chunks for debugging set echo = FALSE. {r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE)

Output Format[edit]

If you want to change the output format, * OFFICE - LibreOffice Write/Word: change the output: setting in header to output: word_document. * PRESENTATION - Web: change the output: setting in header to output: ioslides_presentation: default.

R Markdown[edit]

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Slide with Bullets[edit]

{r echo=FALSE} noten7a <- c(1.0,2.3,4.0,5.0,3.3,4.3)

  • Bullet 1 Mean of marks is r mean(noten7a) in class 7a.
  • Bullet 2
  • Bullet 3

Tables[edit]

{r} library(knitr) kable(mtcars[1:5,1:3],caption="My KnitR Table")

Slide with R Output[edit]

{r cars, echo = TRUE} summary(cars)

Slide with Plot[edit]

{r pressure} plot(pressure)

Histogramme[edit]

Zufallszahlen generieren {r echo=TRUE} meine_daten <- rnorm(10,mean=20,sd=15)

Datenausgabe[edit]

{r} meine_daten Befehlsausgabe ohne Evaluation der R-Befehle: {r echo=TRUE} x <- seq(0, 2*pi,length.out=50) y <- sin(x)

Plot der Sinuskurve[edit]

{r echo=TRUE} x <- seq(0, 2*pi,length.out=50) y <- sin(x) plot(x,y)

Histogramme[edit]

{r} hist(meine_daten,10)

Plots[edit]

{r} x <- seq(0, 2*pi,length.out=50)

Daten laden[edit]

{r} library(readxl) dataset <- read_excel("testdata.xls") # View(dataset) kable(dataset,caption = "File: testdata.xls")

Daten schreiben[edit]

{r echo=TRUE} library(readxl)