-
Notifications
You must be signed in to change notification settings - Fork 0
/
requirements.R
65 lines (59 loc) · 2.39 KB
/
requirements.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
60
61
62
63
64
65
#`%+%`<- function(x,y) {paste(x,y,sep = "")}
`%#%` <- function(x,y) {paste(x,y,sep = "")}
`%-%` <- function(x,y) {paste(x,y,sep = "-")}
`%_%` <- function(x,y) {paste(x,y,sep = "_")}
`%,%` <- function(x,y) {paste(x,y,sep = ",")}
`%, %` <- function(x,y) {paste(x,y,sep = ", ")}
`% %` <- function(x,y) {paste(x,y,sep = " ")}
`%: %` <- function(x,y) {paste(x,y,sep = ": ")}
`%//%` <- function(a,b) {paste(a,b,sep = "/")}
# note %/% is remainder of division modulo!!!
ma <- function(x, n = 7, na.rm = TRUE, ...) { #... = sides=2
n = min(length(x),n)
cx <- stats::filter(x, rep(1 / n, n), method = "convolution", ...)
if ( na.rm) cx <- ifelse(is.na(cx),x,cx)
cx}
mac <- function(x,minval=5, ...){
cx <- ma(x,...)
#cx <- ifelse(is.na(cx),x,cx)
ifelse(abs(cx) < minval, x, cx )
}
#pacman p_load automates this and the following also:
#automate the syntax... Thanks Simon https://stackoverflow.com/users/1478381/simon-ohanlon
getPackages <- function(x){
for (i in x ) {
# require returns TRUE invisibly if it was able to load package
if ( !require( i , character.only = TRUE, quietly = TRUE ) ) {
# If package was not able to be loaded then re-install
install.packages( i , dependencies = TRUE )
# Load package after installing
require( i , character.only = TRUE )
}
}
}
getPackages <- function(x){
lapply(x,function(i){
# require returns TRUE invisibly if it was able to load package
if ( !require( i , character.only = TRUE, quietly = TRUE ) ) {
# If package was not able to be loaded then re-install
install.packages( i , dependencies = TRUE )
# Load package after installing
require( i , character.only = TRUE )
}
})
}
suppressPackageStartupMessages({
getPackages(c("lubridate",'rvest',"plyr","lubridate", "scales", "reshape2", "tidyverse",'profvis',
"RColorBrewer","ggthemes", "directlabels", "ggrepel","JuliaCall", "reticulate"))
#"plm",#"scales","ggplot2",
})
#if (!require(devEMF)){ install.packages('devEMF') require(devEMF)}
#for other formats of saving of plots
mutate_cond <- function(.data, condition, ..., envir = parent.frame()) {
condition <- eval(substitute(condition), .data, envir)
.data[condition, ] <- .data[condition, ] %>% mutate(...)
.data
}
#install.packages("JuliaCall")
library(JuliaCall)
#julia <- julia_setup(JULIA_HOME = "C:/Users/feltkamp/AppData/Local/Programs/Julia/Julia 1.5.0/bin")