forked from slycoder/Rpipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRpipe.jjplot.R
49 lines (42 loc) · 1.2 KB
/
Rpipe.jjplot.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
################################
# Initial Rpipe interface for jjplot
################################
## Need to do checks on e1 = jjplot.state?
## both jjplot.stat.foo and jjplot.geom.foo
Rpipe.prefix.jjplot.state <- function(e1) {
c("jjplot.stat",
"jjplog.geom",
"Rpipe",
"")
}
jjplot.data <- function(data, ...) {
structure(list(data = transform(data, ...)),
class = "jjplot.state")
}
jjplot.range <- function(state, ...) {
list(x = range(state$data$x),
y = range(state$data$y))
}
jjplot.geom <- function(plot.function,
range.function = jjplot.range) {
## Add extra info here!
function(state, ...) {
structure(list(plot.function = plot.function,
range = range.function(state, ...),
state = state),
class = "jjplot.goem")
}
}
## Logic for scales:
## Two aspects
## 1.) ticks
## 2.) range
## range should be union of numeric ranges
## ticks depend on type
## numeric - pretty
## factor - at ticks
## cast numeric -> factor
## check if factors equal.
jjplot.data(iris) %|%
aggregate(Species, Mean.Sepal.Width = mean(Sepal.Width)) %|%
transform(x = Species, y = Mean.Sepal.Width)