Everything is due by 5PM next Tuesday.
- The PR to the class website described below.
- Create a new repository for your R markdown work.
- Take the HTML output from the R markdown "knit" step and put it in that repo.
- Also put the original "Rmd" file there.
- The README for your new repo will provide answers to the specific questions asked below.
- Add a link from your "homework website" to your new repository. This link should be in a new subsection (two hashes!) on your website's main page.
- Notify me via a DM on Discord when this is done. Not email. Not Canvas. Do not add me as a collaborator. (I get scores of GitHub notifications per day due to the organizations that I'm a part of. I'll simply never see the notification adding me to collaborate.)
Do not wait until the last minute! Many of you are guaranteed to run into technical issues!!
- Make sure you are set up to use R studio to generate reports in the R Markdown format.
- Demonstrate the amazing ability to do the following:
- Execute both R and Python code in a common environment
- Exchange data between the 2 languages!
- Generate a plot using Python code from data that originated on the R side.
- You will learn, by osmosis, about several R, R Markdown, and Python features.
You will submit a pull request to the class website repository.
This PR will:
- Add a file called
name.mdwherenameis your first name. For example, mine would be calledkevin.md. - The contents of this file will be a hyperlink to the web page that you created last week.
- The link text will be
FirstName LastName.
For example, mine would readKevin Thornton.
So, you were asked to have both of these installed by today (Thursday).
If you haven't done this, then do so now.
Remember to get your "channels" set up so that you can use bioconda!
Install the following package(s) into R Studio (using the "install packages" bit of the interface):
- reticulate
- nycflights13
- ggplot2
Install the following package(s) via conda:
- pandas
- seaborn
Now, in a new R Markdown document in R Studio, enter the following code:
```{r}
library(nycflights13)
data(flights)
```
```{python}
import pandas
print(type(r.flights))
print(r.flights)
```
At the top of a new R Markdown, there's a "setup" block that often looks like:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
In this block, you'll want to state that you are using reticulate.
Some of you may need to also tell the system where your Python executable is:
- What function does that?
- What shell command do you use to find your Python path?
- What does
include = FALSEdo?
You'll have to figure out how to point your Rstudio to the Python binary on your Ubuntu system. Let us know how to do that! ;)
Press the knit button.
Fingers crossed, you should see a window pop up with an HTML rendering generated from your markdown.
With that working (famous last words), add the following markdown code to your document:
```{r}
data(mtcars)
```
```{python}
print(r.mtcars.head())
```
```{python}
import seaborn as sns
import matplotlib.pyplot as plt
g = sns.FacetGrid(r.mtcars, col="cyl")
g.map(sns.scatterplot,"wt","mpg");
plt.show()
```
- What happens if you remove the semicolon (';') from the second to last line of the last code block?