<jupyter_start><jupyter_text>Sample Lecture - R   Overview This is a short and quick presentation of the available elements, which can be used to build up your lecture notes.The big advantage is, that you have to build the document only once. You can include code, models, algorithms you are currently working on. Enrich them with notes and explanations for your students. Once, it's time for lectures you just need to mark which elements should be included into the presentation and commit the changes to github. [Notebook-Classroom](https://github.com/hydrocode-de/notebook-classroom) will take care of the rest. You will notice that this cell will be ignored in the presentation, because it's slide type was set to ``skip``. The next cell will import some important packages. If you use interactive plots, like Bokeh or plotly, you generally need to markthese cells as ``notes``. The difference is that these cells will not be shown, but *included* (as notes in presentation mode), whereas ``skip`` cells will be *removed*.<jupyter_code>library(ggplot2)
library(gridExtra)
library(vembedr)<jupyter_output>Registered S3 methods overwritten by 'ggplot2':
  method         from 
  [.quosures     rlang
  c.quosures     rlang
  print.quosures rlang<jupyter_text>Text Formatting With markdown its **easy** to format text like *italics* or _**bold and italics**_.By leaving a blank line, a new paragraph is started. Some inline $math^3_{i,j}$ can be added easily. Of course it's also possible to put formulas into their own line.$$E=mc^2$$See the source for this formatted cell below: ```With markdown its **easy** to format text like *italics* or _**bold and italics**_.By leaving a blank line, a new paragraph is started. Some inline $math^3_{i,j}$ can be added easily. Of course it's also possible to put formulas into their own line.$$E=mc^2$$See the source for this formatted cell below:```  Code It is also possible to include code that is not meant to be run (which would go into a code cell then). Most programming languages will be syntax-highlighed when included.```pythonprint('Like Python')``````rv <- "But also R"``````c++cout << sprintf(buffer, "C++ is also %s", "known") << endl;```  More, More, Moreof course there is way more. You will find some pretty good cheat-sheets out there: e.g. [this one](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)  Running Code The main advantage of using jupyter notebooks is obviously the ability to run code. We can perform calculations and explore the result interactively with the students. These cells even make it possible for students, who have never programed to change existing code with ease. We will generate some $(x, y)$ tuples with $0 < x < 2\pi$ and $$ y = sin(x) + r $$where $r$ is a random number $-0.1 < r < 0.1$<jupyter_code># generate some data
x <- seq(0, 2*pi, length.out=100)

# sine
y <- sin(x) + runif(100, -.1, .1)<jupyter_output><empty_output><jupyter_text>The notebook will render any output to StdOut and StdErr.<jupyter_code>y<jupyter_output><empty_output><jupyter_text>Plotting The maybe coolest feature is the ability to directly inject and show plots.The standard R plotting library is right away available and whenever a plotting object is passed to StdOut, the notebook will render it<jupyter_code>options(repr.plot.width=6, repr.plot.height=4)
plot(x, y, type="o")
df <- data.frame(x, y, sin(x) - y)
names(df) <- c('x', 'y', 'd')
p1 <- ggplot(df, aes(x=x, y=y)) + 
        geom_line(color="red")
p2 <- ggplot() + 
    geom_bar(data=df, aes(x=x, y=d), stat="identity", 
             fill="blue", show.legend=F, width=0.02)
options(repr.plot.width=6, repr.plot.height=3)
grid.arrange(p1, p2, nrow=2)<jupyter_output><empty_output><jupyter_text>Videos Sometimes it's very helpful to include a video into a notebook. There are various ways how to do that. As Notebooks are capable of rendering HTML tags, you can include the video using a ordinary ``iframe``. This is however not a good idea, as many Markdown processors will exclude tags like ````, ```` or ```` from the markdown source before rendering it.Thus, we need the ``vembedr`` package<jupyter_code>embed_youtube('XTsaZRKx9UI', width=840, height=450) %>% use_start_time("5s")<jupyter_output><empty_output><jupyter_text>Tables There are many way to include tables. You can use Markdown markup to create tables. You can use HTML ```` tags. This is both fine, but a  lot of work if you need to create large tables. The third option is to use code cells to render tables. I.e. ``data.frame`` objects will render to tables if you print them to StdOut. This way you can keep the table data in a csv and read and render it in a one-liner.  Markdown This table:| head 1 | head 2 | head 3 ||--------|--------|--------|| cell 1 | cell 2 | cell 3 || cell 4 | cell 5 | cell 6 || cell 7 | cell 8 | cell 9 |can be created like:```| head 1 | head 2 | head 3 ||--------|--------|--------|| cell 1 | cell 2 | cell 3 || cell 4 | cell 5 | cell 6 || cell 7 | cell 8 | cell 9 |```  HTML The same as HTML table:    head 1head 2head 3    cell 1cell 2cell 3    cell 4cell 5cell 6    cell 7cell 8cell 9can be created like:```html    head 1head 2head 3    cell 1cell 2cell 3    cell 4cell 5cell 6    cell 7cell 8cell 9```  R<jupyter_code>df<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup