-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRprofile.site
80 lines (64 loc) · 1.75 KB
/
Rprofile.site
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
# Things you might want to change
# options(papersize="a4")
# options(editor="notepad")
# options(pager="internal")
# set the default help type
# options(help_type="text")
options(help_type="html")
# set a site library
# .Library.site <- file.path(chartr("\\", "/", R.home()), "site-library")
# set a CRAN mirror
# local({r <- getOption("repos")
# r["CRAN"] <- "http://my.local.cran"
# options(repos=r)})
# Give a fortune cookie, but only to interactive sessions
# (This would need the fortunes package to be installed.)
# if (interactive())
# fortunes::fortune()
## Own additions:
# Copy this to R_HOME
# That directory can be found with:
# System.getenv("R_HOME")
repo="d:/experimental/data-science1"
r.home = Sys.getenv("R_HOME")
printf = function(format, ...) {
message(sprintf(format, ...))
}
print.file = function(file,max.lines=10) {
if(max.lines=="all")
max.lines=-1L
printf("Contents of file '%s'", file)
cat(readLines(con=file,encoding="UTF-8",n=max.lines),sep="\n")
}
cd = function (directory="ex") {
path=sprintf("%s/%s", repo, directory)
setwd(path)
printf("Working directory now: %s", path)
printf("Files:")
list.files()
}
profile.file = function() {
r.home = Sys.getenv("R_HOME")
sprintf("%s/etc/Rprofile.site", r.home)
}
profile.open = function () {
shell.exec(profile.file())
}
profile.copy = function () {
file.copy(profile.file(), repo, overwrite=T)
printf("Profile copied.")
}
freq.table = function(values,frequencies) {
index = 0
output=c()
for( x in c(1:length(values))) {
freq=frequencies[x]
value=values[x]
for(i in c(1:freq)) {
index = index + 1
output[index] = value
}
}
return(output)
}
cd()