Knit early. Knit often.
The following section makes more sense in the code than in the
html
Insert an R code chunk by using the insert button
above. Shortcut keys Ctrl+Alt+i should create a chunk but if not, this
can be set by choosing your own shortcut in Tools/Keyboard Shortcuts
Help.
A code chunk looks like this:
You can name a chunk (optional), like so
The next chunk should be familiar; it’s the code to import the beds
data. Code has been copied across but code can be written directly into
the chunk.
Knit the file
By clicking on the drop down menu beside the Knit
button, a document will be generated (note: first time you do this,
you’ll be prompted to name your file. Try “test_rmarkdown”). As PDF
requires additional installations, we will knit to HTML (web page) for
now, which is the default and also better for accessbility.
Text
Markdown formatting
LS0tCnRpdGxlOiAiSW50cm9kdWN0aW9uIHRvIFJNYXJrZG93biIKZGF0ZTogImByIGZvcm1hdChTeXMudGltZSgpLCAnJWQgJUIgJVknKWAiCm91dHB1dDoKICBodG1sX2RvY3VtZW50OgogICAgY29kZV9kb3dubG9hZDogeWVzCiAgICB0b2M6IHRydWUKICAgIHRvY19kZXB0aDogNAogICAgdG9jX2Zsb2F0OiB0cnVlCi0tLQoKYGBge3Igc2V0dXAsIGluY2x1ZGUgPSBGQUxTRX0KbGlicmFyeShrbml0cikKbGlicmFyeSh0aWR5dmVyc2UpCgpvcHRzX2NodW5rJHNldCgKICBlY2hvID0gRkFMU0UsCiAgZXZhbCA9IEZBTFNFLAogIG1lc3NhZ2UgPSBGQUxTRSwKICB3YXJuaW5nID0gRkFMU0UsCiAgZmlnLndpZHRoID0gNy4yNTIsCiAgZmlnLmhlaWdodCA9IDQsCiAgZHBpID0gMzAwLAogIGRldi5hcmdzID0gbGlzdCh0eXBlID0gImNhaXJvIikKKQpgYGAKCgojIEtuaXQgZWFybHkuIEtuaXQgb2Z0ZW4uIAoKIyMgVGhlIGZvbGxvd2luZyBzZWN0aW9uIG1ha2VzIG1vcmUgc2Vuc2UgaW4gdGhlIGNvZGUgdGhhbiBpbiB0aGUgaHRtbAoKSW5zZXJ0IGFuIFIgY29kZSBjaHVuayBieSB1c2luZyB0aGUgKippbnNlcnQqKiBidX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