-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirstRmarkdown.Rmd
More file actions
121 lines (86 loc) · 3.39 KB
/
firstRmarkdown.Rmd
File metadata and controls
121 lines (86 loc) · 3.39 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: "firstRmarkdown"
output:
html_document:
toc: true
toc_float: true
number_sections: true
fig_width: 7
fig_height: 6
fig_caption: true
date: "2022-11-29"
bibliography: biblio.bib
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE) # settings for the whole doc
#echo to show code or not
#eval to show results or not
#include = false means echo and eval and xx is false
```
yaml (yet another markup langage) allows to add table of content. Careful with the indentation (2 spaces).
## R Markdown {-}
The {-} removes the number next to that title.
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars, echo=TRUE, eval=TRUE}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
```{r table}
library(DT) #only works for html outputs
DT::datatable(iris,
rownames=FALSE,
options=list(pagelength=10,
scrolly="100px"))
#cars %>% head(5) %>%
```
## References
Note: we can add ref with bibtex (use Zotero!).
Ref are added by doing [@kefi_early_2014].
Zotero style bibliography to find journal styles for ref.
then we save the csl file in the folder.
then we add this in the yaml (at the start of the doc): "csl: science.csl"
Otherwise, by default it is the Rmarkdown style.
## Package rticle
R package that provides templates for articles.
<https://github.com/rstudio/rticles>
## Websites
Use package blogdown to build a website.
## Create a simple website
create a new project
ditill website
click all left ooptions
on the right: click hugo if not install (other unclixked)
Choose hugo theme: go to hugo website gohugo.io
e.g. beautiful hugo theme
find link to github, clik on it (github repo)
copy the github account and name of repo and paste it in the theme in R eg halogenica/beautifulhugo
--> creates everything we need
in console: blogdown::serve_site()
I get a localhost adddress which can be pasted in firefox to see the page
blogdown::build_site()
creates the html files
now we want to put this webpage on github:
(after having initiated git in the project, ie 'git init' in the folder, 'git add .', 'git commit - m "init"')
delte the gitignore
rcompedndium::add_to_gitignore
usethis::use_github()
pushed the project to github
pour le déployer,
dir.create(".github.workflows", recursive=TRUE)
then create textfile blogdown.yml (and copy texte from another website but change name)
commit the changes
git add., git commit, git push
on github, if we now go to "actions" (onglet), there should be something (the setup of the server). Cliquer sur setup
(dans onglet "settings", pages: branch: main, /root
we need to have index.html at the root of the folder)
blogdown creates a new branch and knits the index.html --> branch is gh-pages (in settings/pages)
and we leave root
The website is now available at https//skefi.github.io/mywebsite
Bookdown.org
# Bibliography