-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathf2.Rmd
More file actions
32 lines (24 loc) · 1.35 KB
/
f2.Rmd
File metadata and controls
32 lines (24 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
---
title: "Function 2"
output:
html_document:
df_print: paged
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.
```{r}
library(tidyverse)
data<-diamonds
data2 <- data %>% slice(-c(301:53940))
diamond.function <- function(color1,facet2="NULL"){
plt2<-ggplot(data = data2, mapping = aes(x = carat, y = price)) + geom_point(col = color1) + stat_smooth(method = "lm", col = "red") + labs(x = "Carat", y = "Price", title = "ScatterPlot of Dimond Weight (carat) and Price (price)")
if(!facet2=="NULL"){
return(plt2 + facet_grid(color~.))
}
return(plt2)
}
diamond.function("purple")
```
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Ctrl+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.