-
Notifications
You must be signed in to change notification settings - Fork 0
/
everyday
59 lines (57 loc) · 2.21 KB
/
everyday
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
# Everyday set-up
require("tidyverse")
options(tibble.print_min = 15)
options(tibble.print_max = 25)
options(stringsAsFactors = FALSE)
left <- function(text, numchars = nchar(text)){
result <- substr(text, 1, numchars)
return(result) }
right <- function(text, numchars = nchar(text)){
result <- substr(text, nchar(text) - (numchars - 1), nchar(text))
return(result) }
mid <- function(text, startnum = 1, numchars = nchar(text)){
result <- substr(text, startnum, (startnum + numchars - 1))
return(result) }
left_str <- function(textt, pat) {
result <- sapply(seq_along(textt), function(x) {
substr(textt[[x]], 1, str_locate(textt[[x]], pat)[,1] - 1) } )
return(result) }
right_str <- function(textt, pat) {
result <- sapply(seq_along(textt), function(x) {
substr(textt[[x]], str_locate(textt[[x]], pat)[,1] + 1, nchar(textt[[x]])) } )
return(result) }
C <- "C:/Users/I816544"; Z <- "Z:/QTPLANMAINT/Rating"
createDir <- function(subdirs) {
lapply(seq_along(subdirs), function(y) {
dir.create(file.path(C, "Downloads", subdirs[[y]]))
} )
}
file.details <- function(drive = C, pathh = "Documents/R/win-library") {
filenames <- file.path(drive, pathh) %>% list.files()
fileinfo <- suppressWarnings(lapply(seq_along(filenames), function(x) {
file.path(drive, pathh, filenames[[x]]) %>% file.info()
} ) %>%
bind_rows() %>% as_tibble() %>% mutate(name = filenames) %>%
select(name, mtime, isdir, atime, size, ctime) %>%
arrange(desc(isdir), desc(mtime), desc(atime), desc(size), name))
return(fileinfo)
}
idCheck <- function(lis) {
lapply(seq_along(lis), function(y) {
sapply(seq_along(lis), function(x) {
identical(lis[[y]], lis[[x]]) }) %>% which() }) }
time.taken <- function(x, ...) {
start_time <- Sys.time(); x; end_time <- Sys.time()
return(list(x, end_time - start_time))
}
dayScriptswd <- function() {
setwd("C:/Users/I816544/Documents/R/win-library/dayScripts") }
regularwd <- function() {
setwd("C:/Users/I816544/Documents/R/win-library") }
dayScriptswd()
newDailyScript <- paste0(mid(date(), 5, 3), mid(date(), 9, 2),
right(date(), 2), ".R")
file.edit(newDailyScript)
regularwd()
file.edit("pivotScript.R")
withAutoprint(print("everyday_script.R read and sourced!"))