-
Notifications
You must be signed in to change notification settings - Fork 22
/
tests.R
77 lines (48 loc) · 2.03 KB
/
tests.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
65
66
67
68
69
70
71
72
73
74
library(scatterD3)
mtcars$names <- rownames(mtcars)
i <- function() { devtools::install() }
## AUTO LABELS
i(); scatterD3(data=mtcars, wt, mpg,
lab=names, labels_positions="auto")
i(); scatterD3(data=mtcars, wt, qsec,
lab=names, labels_positions="auto")
d <- data.frame(lab = "toto", x = rnorm(100), y = rnorm(100))
i(); scatterD3(data=d, x, y,
lab=lab, labels_positions="auto")
d <- data.frame(lab = "toto", x = rnorm(501), y = rnorm(501))
i(); scatterD3(data=d, x, y, lab=lab, labels_positions="auto")
d <- data.frame(lab = c(rep("toto", 100), rep("", 401)), x = rnorm(501), y = rnorm(501))
i(); scatterD3(data=d, x, y, lab=lab, labels_positions="auto")
## SIZES
i(); scatterD3(data=mtcars, wt, mpg, size_var = qsec)
i(); scatterD3(data=mtcars, wt, mpg, size_var = cyl)
sizes <- c(`4` = 10, `6` = 50, `8` = 200)
i(); scatterD3(data=mtcars, wt, mpg, size_var = cyl, sizes = sizes)
sizes <- c(`4` = 10, `6` = 50)
i(); scatterD3(data=mtcars, wt, mpg, size_var = cyl, sizes = sizes)
## OPACITIES
i(); scatterD3(data=mtcars, wt, mpg, opacity_var = cyl)
opacities <- c(`4` = 1, `6` = 0.2, `8` = 0.5)
i(); scatterD3(data=mtcars, wt, mpg, opacity_var = cyl, opacities = opacities)
opacities <- c(`4` = 1, `6` = 0.2)
i(); scatterD3(data=mtcars, wt, mpg, opacity_var = cyl, opacities = opacities)
## ARROWS
df <- data.frame(x= runif(5) - 0.5, y = runif(5) - 0.5, lab = "toto")
i(); scatterD3(x=df$x, y=df$y, lab=df$lab, type_var = rep("arrow", 5))
## LEGENDS
i(); scatterD3(data=mtcars, wt, mpg, col_var = cyl, col_lab = NA)
i(); scatterD3(data=mtcars, wt, mpg, col_var = cyl, size_var = qsec, size_lab = NA)
df <- mtcars
df$cyl[df$cyl==4] <- ""
i(); scatterD3(data=df, wt, mpg, col_var = cyl)
## CODE FOR DEMO GIF
library(scatterD3)
mtcars2 <- mtcars[sample(1:nrow(mtcars), 15),]
mtcars2$name <- rownames(mtcars2)
scatterD3(data = mtcars2,
x = mpg, y = wt, col_var = cyl, size_var = qsec, symbol_var = am,
symbol_lab = "Transmission", col_lab = "Cylinders",
size_lab = "1/4 mile time",
lab = name, labels_positions = "auto",
lasso = TRUE
)