-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhorrifying_r_features.txt
More file actions
27 lines (21 loc) · 1.2 KB
/
horrifying_r_features.txt
File metadata and controls
27 lines (21 loc) · 1.2 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
assign is a function, as in
x <- 2 is equivalent to assign("x", 2)
attribute setting is done by assigning to an output function, like
attr(x, "attribute_of_x") <- 50
periods in names are just characters, they hold no special semantic value
so having a function
as.date()
and another
as.date.POSIX()
are just two random funciton names that have no underlying linkage
The ternary operator is just a function called ifelse, so
ifelse(x > 5, "x was greater than 5", "x was not greater than 5")
The existence of return and invisible as functions to control return values the way that they do
As best I can tell, the way methods are implemented relies only on the name of a function.
That's right, it's just what ever the function's name is, that string identifies the class at the end, and that's how R knows which funciton to use for a class.
Inheritance is performed by putting the superclass's name in the list of strings in the class attribute. That's it.
The existence of a function names `map2`, which is the way to map over two iterables at once:
x <- c(1, 2, 3)
y <- c(4, 5, 6)
map(x, ~do_thing_with_input(.)) #prints all in x
map2(x, y, func_that_takes_x_and_y_as_params) # this is the best way r has to handle this