-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.Rmd
More file actions
76 lines (64 loc) · 2.2 KB
/
Copy pathindex.Rmd
File metadata and controls
76 lines (64 loc) · 2.2 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
---
title: 'HarvardX PH125.9x: Movielens project'
author: "Yin-Chi Chan"
date: "`r Sys.Date()`"
documentclass: article
mainfont: Times New Roman
mathfont: Cambria Math
monofont: Cascadia Code
geometry: margin=2.5cm
bibliography: book.bib
biblio-style: acm
description: |
See also: _output.yml, _bookdown.yml
link-citations: yes
site: bookdown::bookdown_site
---
# Preface {-}
This book is available in both
[HTML gitbook](https://yinchi.github.io/harvardx-movielens/index.html) and
[PDF](https://yinchi.github.io/harvardx-movielens/movielens.pdf) form.
The source code in the PDF version of this report is typeset in
[Cascadia Code](https://github.com/microsoft/cascadia-code), with code ligatures enabled.
A similar font, [Fira Code](https://github.com/tonsky/FiraCode), is used in the HTML version.
## R setup
```{r Setup, include=FALSE, purl=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE,
dpi = 144
)
# https://stackoverflow.com/questions/25646333/#46526740
def.chunk.hook <- knitr::knit_hooks$get("chunk")
if (knitr::is_latex_output()) {
knitr::knit_hooks$set(chunk = function(x, options) {
x <- def.chunk.hook(x, options)
paste0("\n \\", "small","\n\n", x, "\n\n \\normalsize")
})
}
```
```{r Load-libraries}
# R 4.1 key features: new pipe operator, \(x) as shortcut for function(x)
# R 4.0 key features: stringsAsFactors = FALSE by default, raw character strings r"()"
if (packageVersion('base') < '4.1.0') {
stop('This code requires R >= 4.1.0!')
}
if(!require("pacman")) install.packages("pacman")
library(pacman)
# Ensure packages are installed but do not load them
p_install(Rcpp, force = F)
p_install(RcppArmadillo, force = F)
p_install(RcppProgress, force = F)
p_install(recommenderlab, force = F)
p_install(rrecsys, force = F)
p_install(mgcv, force = F) # provides mgcv::gam and mgcv::predict.gam
p_install(raster, force = F) # provides raster::clamp
# Load these packages
p_load(conflicted, magrittr, knitr, kableExtra, data.table, latex2exp, patchwork,
tidyverse, caret, lubridate)
# For functions with identical names in different packages, ensure the
# right one is chosen
conflict_prefer('RMSE', 'caret')
conflict_prefer("first", "dplyr")
```