-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.R
More file actions
executable file
·32 lines (27 loc) · 828 Bytes
/
temp.R
File metadata and controls
executable file
·32 lines (27 loc) · 828 Bytes
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
print("hello world") # works
print("hi world") # works
ls # fails
a <- 1
print(a)
print("hello")
extract_path_from_obj <- function(obj, path_within_obj) {
if (length(path_within_obj) == 0) {
return (obj)
} else {
extract_path_from_obj(obj[[path_within_obj[1]]], path_within_obj[-1])
}
}
assign_to_path <- function(current_obj, path_within_obj, assignment) {
current_entry <- path_within_obj[1]
print(current_entry)
if (length(path_within_obj) == 1) {
return (current_obj[[current_entry]] <- assignment)
}
path_within_obj <- path_within_obj[-1]
current_obj[[current_entry]] <- assign_to_path(current_obj[[current_entry]], path_within_obj, assignment)
current_obj
}
fit <- lm(speed ~ ., cars)
str(fit)
fit <- assign_to_path(fit, c("model", "dist"), 1)
str(fit)