-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_script.R
More file actions
121 lines (71 loc) · 1.63 KB
/
Copy pathtest_script.R
File metadata and controls
121 lines (71 loc) · 1.63 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
library(devtools)
library(tidyverse)
install()
document()
load_all()
example_data <- tibble(
x = rnorm(300, 20, 10),
y = rnorm(300, 5, 2),
z = rnorm(300, 10, 4)
) %>% mutate(y = y * x ^ 2)
modify_data <- TRUE
isReallyTRUE <- function(x) {
isTRUE(y)
}
bottle <- bottle_code({
if(isTRUE(modify_data)) {
prep_data <- example_data %>%
mutate(y = y * 10)
}
p <- ggplot(prep_data, aes(x, y)) +
geom_point() +
labs(x = "", y = y_axis_name)
p + theme_bw()
}, debug = TRUE)
bottle
run_bottle(bottle)
save_bottle(bottle, "test_bottle.rds")
bottle <- load_bottle("test_bottle.rds")
bottle
run_bottle(bottle)
bottle_keywords('{
# Doing something here
"Some very long string"
1 + 1 # Math
\'Some other string\'
}')
document()
load_all()
crate <- Crate$new()
crate$bottle("A")({
1 + 1
})
crate$run_bottle("A")
crate$get_bottle("A")
crate$bottle("A", "B")({
x <- 50 + 50
x * 100
})
crate$run_bottle("A", "B")
crate$get_bottle("A", "B")
modify_data <- FALSE
crate$bottle("example_data", "figure")({
if(isTRUE(unshare(modify_data))) {
prep_data <- example_data %>%
mutate(y = y * 10)
} else {
prep_data <- example_data
}
p <- ggplot(prep_data, aes(x, y)) +
geom_point()
p + theme_bw()
})
crate$get_bottle("example_data", "figure")
crate$run_bottle("example_data", "figure")
crate
crate$save("crate.rda")
crate2 <- Crate$new(filename = "crate.rda")
big_number <- 10000000000000000000000000000
crate2$add_to_env(big_number)
ls(parent.env(crate2$get_bottle("A", "B")$env))
get("big_number", envir=crate2$get_bottle("A", "B")$env)