-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDay1_course.R
66 lines (43 loc) · 1.41 KB
/
Day1_course.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
.Library ###search for the default path for libraries
.libPaths()
use_course("rstd.io/wtf-explore-libraries")
installed.packages() %>% as_tibble() %>% count(Built)
list.files(.Library)
###library: fs
###for directory and file system handling
dir_info()
dir_ls()
fs::path_home()
good<- fs::path_home("tmp/test.csv") ###get the directory for that newly created file
good
dir_create("figs") ###create a new folder figs under current wd
dir_ls(glob = "*.R") ###search for all R programs
###library:here
library(here)
here::here("*.md")
system("tree")
###here() function is not for creating directories
ggsave(here("figs", "built-barchart.png")) ###perfect for creating the location
dir_ls(here("figs"))
if(dir_exists(here("figs"))){
dir_create(here("figs"))
}
dir_delete(here("new")) ###One-time shot
####file names
ft<- tibble(files=dir_ls(glob = "*.R")) ####search for all R programs under current WD
ft %>% filter(str_detect(files,"course")) ###filter out the programs that contains the course word
ft %>% mutate(files=path_ext_remove(files)) %>% separate(files,into=c("Day","Topic"),sep="_")
###take-away: separate() function
###path_ext_remove() function to remove extension
###usethis
library(usethis)
use_course("rstd.io/wtf-packages-report")
###debugging
f<- function(x){
browser()
str(x)
x+1
}
f("a")
###YAML languages
###output to github_document for rendering md files instead of Rmd and html files