R Studio How to Upload Html File
Getting Started
Let's dive deeper into the R Markdown
file format. This tutorial will introduce you to working with R Markdown
files in R
and R Studio
. You will create an R Markdown
file and render it to html using the knitr
package.
Learning Objectives
At the end of this activity, yous volition:
- Know how to create an
R Markdown
file inRStudio
. - Be able to write a script with text and
R
lawmaking chunks. - Create an
R Markdown
document ready to be 'knit' into anhtml
certificate to share your code and results.
What You Need
You will need the most electric current version of R
and, preferably, RStudio
loaded on your computer to complete this tutorial.
Install R Packages
- knitr:
install.packages("knitr")
- rmarkdown:
install.packages("rmarkdown")
Create a New R Markdown File in RStudio
Watch the 6:38 minute video below to run across how yous convert an R Markdown
file to html
(or other formats) using knitr
in RStudio
. Notation: The text size in the video is small-scale and so you may want to watch the video in total screen mode.
Create Your .Rmd File
Now that you lot come across how R Markdown
tin can be used in RStudio
, yous are prepare to create your own .Rmd
document. Do the post-obit:
- Create a new
R Markdown
file and choosehtml
every bit the desired output format. - Enter a Championship (Globe Analytics Week 1) and Writer Proper noun (your proper noun). Then click OK.
- Save the file using the following format: FirstInitial-LastName-document-your-science/.Rmd NOTE: The certificate title is not the same as the file name.
- Hit the `Knit HTML` drop down push in
RStudio
(equally is done in the video above). What happens?
If everything went well, you should have an html
format (web page) output later on you lot hitting the knit button. Annotation that this html
output is built from a combination of code and text documentation that was written using markdown syntax.
Don't worry if yous don't know what markdown is. You will larn that in the next lesson.
Next, let's intermission down the structure of an R Markdown
file.
The Structure of an R Markdown File
Data Tip: Screenshots on this page are from RStudio
with appearance preferences set to Twilight
with Monaco
font. You can change the appearance of your RStudio by Tools > Options (or Global options depending on the operating organisation). For more than, come across the Customizing RStudio folio.
There are iii parts to an .Rmd
file:
- Header: The text at the superlative of the document, written in YAML format.
- Markdown sections: Text that describes your workflow written using markdown syntax.
- Code chunks: Chunks of
R
lawmaking that can be run and as well tin be rendered usingknitr
to an output document.
Next, let'south suspension down each of the parts listed above.
An R Markdown file always starts with a header written using YAML syntax. This header is sometimes referred to every bit the front matter
.
At that place are four default elements in the RStudio
YAML
header:
- title: The title of your document. Notation, this is not the same as the file name.
- author: Who wrote the document.
- appointment: By default this is the engagement that the file is created.
- output: What format volition the output exist in. You will use
html
.
Notation that a YAML header begins and ends with three dashes ---
. Besides discover that the value for each chemical element, championship, author, etc, is in quotes "value-here"
next to the element. A YAML header may be structured differently depending upon how your are using it. Learn more on the R Markdown documentation page.
Example YAML header in an RStudio
R Markdown
file:
--- title: "title" author: "Your Name" date: "December 4, 2016" output: html_document ---
R Markdown Text & Markdown Blocks
The second part of a R Markdown
document is the markdown itself which is used to add documentation to your file (or write your written report). You will larn markdown in the next tutorial.
Activeness: Customize Your R Markdown File's Front Matter - YAML
Customize the header of your .Rmd
file equally follows:
- Championship: Provide a title that fits the code that will be in your RMD.
- Writer: Add your name here.
- Date: Today's date.
- Output: Leave the default output setting:
html_document
.You volition be rendering anhtml
file.
Source: https://www.earthdatascience.org/courses/earth-analytics/document-your-science/intro-to-the-rmarkdown-format-and-knitr/
0 Response to "R Studio How to Upload Html File"
Post a Comment