Skip to main content

R Markdown Notes - P2

R functions sometimes return messages, warnings, and even error messages. By default, R Markdown will include these messages in your report. You can use the message, warning and error options to prevent R Markdown from displaying these. If any of the options are set to FALSE R Markdown will not include the corresponding type of message in the output.

``{r warning = FALSE, error = FALSE}
"four" + "five"
```


Three of the most popular chunk options are echo, eval and results.

If echo = FALSE, R Markdown will not display the code in the final document (but it will still run the code and display its results unless told otherwise).

If eval = FALSE, R Markdown will not run the code or include its results, (but it will still display the code unless told otherwise).

If results = 'hide', R Markdown will not display the results of the code (but it will still run the code and display the code itself unless told otherwise).


You can embed R code into the text of your document with the `r `

An interesting feature available in knitr is the labeling of code snippets.

The code chunk below would be assigned the label simple_sum:

```{r simple_sum, results = 'hide'}
2 + 2
```

knitr provides the option ref.label to refer to previously defined and labeled code chunks. If used correctly, knitr will copy the code of the chunk you referred to and repeat it in the current code chunk. This feature enables you to separate R code and R output in the output document, without code duplication.

```{r ref.label='simple_sum', echo = FALSE}
```

You can render the same R Markdown file into several different formats. There are two ways to change a file's output format.
First, you can click the triangle icon next to "Knit HTML" at the bottom of the pane that displays your R Markdown file. This will open a drop down menu that gives you the choice of rendering as an HTML document or a pdf document.
Second, you can change the output field in the YAML block at the top of your document. For example, this YAML block will create an HTML file:
---
output: html_document
---
This one will create a pdf file:

---
output: pdf_document
---
This one will create a MS Word file:

---
output: word_document
---
And this one will create a Markdown file:

---
output: md_document
---


But what if you are using R in a terminal window? You can run the command rmarkdown::render(<file path>) to render any .Rmd file with R.


You can also export your file as a slideshow by changing the output field to:

---
output: beamer_presentation
---
which creates a beamer pdf slideshow,

---
output: ioslides_presentation
---
which creates an ioslides HTML slideshow or

---
output: slidy_presentation
---
which creates a slidy HTML slideshow.

R Markdown will start a new slide at each first or second level header in your document. You can insert additional slide breaks with Markdown's horizontal rule syntax:

***
Everywhere you add these three asteriks in your text, pandoc will create a new slide.


Each R Markdown output template is a collection of knitr and pandoc options. You can customize your output by overwriting the default options that come with the template.


For example, the YAML header below overwrites the default code highlight style of the pdf_document template to create a document that uses the zenburn style:

---
title: "Demo"
output:
  pdf_document:
    highlight: zenburn
---


The YAML header below overwrites the default bootstrap CSS theme of the html_document template.

---
title: "Demo"
output:
  html_document:
    theme: spacelab
---

Pay close attention to the indentation of the options inside the YAML header; if you do not do this correctly, pandoc will not correctly understand your specifications. As an example, notice the difference between only specifying the output document to be HTML:

---
output: html_document
---
and specifying an HTML output document with a different theme:

---
output:
  html_document:
    theme: spacelab
---


We can change the CSS style of your HTML output: you can set the theme option of html_document to one of default, cerulean, journal, flatly, readable, spacelab, united, or cosmo.


But what if you want to customize your CSS in more specific ways? You can do this by writing a .css file for your report and saving it in the same directory as the .Rmd file. To have your report use the CSS, set the css option of html_document to the file name, like this

---
title: "Demo"
output:
  html_document:
    css: styles.css
---



Shiny is an R package that uses R to build interactive web apps such as data explorers and dashboards. You can add shiny components to an R Markdown file to make an interactive document.

When you do this, you must ensure that

You add runtime: shiny to the file's YAML header
You use an HTML output format (like html_document, ioslides_presentation, or slidy_presentation).
To learn more about interactivity with Shiny and R, visit shiny.rstudio.com.

ou can also use R Markdown to create reports that use interactive ggvis graphics. ggvis relies on the shiny framework to create interactivity, so you will need to prepare your interactive document in the same ways:

You need to add runtime: shiny to the YAML header
You need to ensure that your output is a HTML format (like html_document, ioslides_presentation, or slidy_presentation)

Comments

Popular posts from this blog

Installing OpenERP on Ubuntu 12.04

1. Install Ubuntu Server with OpenSSH Server.So that you can run your commands from a remote server. 2. Run the following commands to install required depedency sudo apt-get install postgresql postgresql-client python-dateutil python-feedparser python-gdata python-ldap python-libxslt1 python-lxml python-mako python-openid python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi 3. Download Latest Openerp all file wget http://nightly.openerp.com/6.1/releases/openerp_6.1-1-1_all.deb 4. Install openErp server. sudo dpkg -i openerp_6.1-1-1_all.deb sudo apt-get install openerp -f 5. Reboot 6. Access the Web Client using http://ip:8069

20 Extensions for VSCode For Node+Angular2 Development

Here is the list of Extensions which I found important and Interesting. The names are in the form of  Author.Name christian-kohler.npm-intellisense CoenraadS.bracket-pair-colorizer DavidAnson.vscode-markdownlint dbaeumer.jshint donjayamanne.githistory ecmel.vscode-html-css eg2.tslint eg2.vscode-npm-script fknop.vscode-npm formulahendry.auto-close-tag formulahendry.auto-rename-tag HookyQR.beautify humao.rest-client lonefy.vscode-JS-CSS-HTML-formatter mkaufman.HTMLHint msjsdiag.debugger-for-chrome prashaantt.node-tdd rbbit.typescript-hero robertohuertasm.vscode-icons Zignd.html-css-class-completion See the following link to quickly install these extensions. Here is the extension.json . https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions

API-AI

Intents ------ ------ An intent defines how the bot should react to what the user says. An intent in your agent represents a mapping between what a user says and what action should be taken by your product. Every intent you create should correspond to one question. In the intents you will write all the different ways of how those questions may be phrased by your customers. Don’t worry, you won’t have to write all of them. API.AI is using machine learning to train your agent to understand a lot more variations based on the examples you provide in intents. User Says --------- We can have several 'User Says' for a single intent.So we have input many different variations in which the user can as for the same intent. The API.AI platform uses machine learning to train agents to understand more variations of these examples. Even with a small number of examples, the agent can understand a lot of variations. You can try it with this agent. The more examples you add, the better the agent...