forked from JohnsonHsieh/DSC2016-R
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.initCourse.R
executable file
·59 lines (51 loc) · 2.28 KB
/
.initCourse.R
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
if (packageVersion("swirl") < package_version("100.3.1-3")) {
stop("Please upgrade the version of swirl via: `install.packages('swirl', repos = 'http://wush978.github.io/R')`")
}
assign(".get_path",
function(fname) {
path <- file.path(lesPath, fname)
normalizePath(path, mustWork = TRUE)
},
envir = globalenv())
assign("check_then_install",
function(pkg_name, pkg_version) {
if (!suppressWarnings(suppressMessages(require(pkg_name, character.only = TRUE)))) utils::install.packages(pkg_name) else {
if (packageVersion(pkg_name) < package_version(pkg_version)) utils::install.packages(pkg_name)
}
},
envir = globalenv())
assign("check_then_install_github",
function(pkg_name, pkg_version, ...) {
if (!require(pkg_name, character.only = TRUE)) devtools::install_github(...) else {
if (packageVersion(pkg_name) < package_version(pkg_version)) devtools::install_github(...)
}
})
assign(".read.table.big5",
function(file, header = FALSE, sep = "", ...) {
info <- l10n_info()
if ("codepage" %in% names(info)) {
read.table(file, header = header, sep = sep, ...)
} else {
read.table(file(file, encoding = "BIG5"), header = header, sep = sep, ...)
}
},
envir = globalenv())
if (!interactive()) {
assign("View", function(x) invisible(x), envir = globalenv())
assign("browseURL", function(x) invisible(x), envir = globalenv())
}
assign("issue", function() browseURL("https://github.com/wush978/DataScienceAndR/issues"), envir = globalenv())
assign("chat", function() browseURL("https://gitter.im/wush978/DataScienceAndR"), envir = globalenv())
assign("source_by_l10n_info", function(path) {
info <- l10n_info()
if (info$MBCS & !info$`UTF-8`) {
try(source(path, local = new.env()), silent = TRUE)
} else {
try(source(path, local = new.env(), encoding = "UTF-8"), silent = TRUE)
}
}, envir = globalenv())
options(
"SWIRL_TRACKING_SERVER_IP" = "api.datascienceandr.org,api2.datascienceandr.org",
"SWIRL_COURSE_VERSION" = "v1.0",
"repos" = c("http://wush978.github.io/R", "CRAN"="http://mran.revolutionanalytics.com/snapshot/2016-04-01")
)