-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdev.R
105 lines (73 loc) · 1.99 KB
/
dev.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
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
library(pacman)
p_load(devtools,usethis,roxygen2,pkgdown,badger)
p_load(fst,stringr,data.table)
document()
#install(upgrade = "never",dependencies = F,quick = T)
install(upgrade = "never",dependencies = F)
#install(quick = T)
.rs.restartR()
rm(list = ls())
library(tidyft)
options(pkgdown.internet = F)
build_site()
# build_vignettes()
submit_cran()
lapply(ls(),get) %>%
lapply(setDT)
library(reprex)
reprex({
library(tidyft)
# get first 5 rows of iris
as.data.table(iris)[1:5] -> a
#show
a
# if you select
a %>% select(1:3)
# you lose the unselected columns forever
a
}, venue = "R") -> res
library(pryr)
a = as.data.table(iris)
mem_change(a[,one:=1] -> b)
mem_change(a[,one:=1][] -> c)
address(a);address(b);address(c)
rm(list = ls())
library(profvis)
library(dplyr)
library(tidyft)
as.data.frame(starwars) -> starwars
starwars[sample.int(1:nrow(starwars),1e6,replace = T),] -> starwars
profvis({
starwars %>%
dplyr::as_tibble() %>%
dplyr::select(name, dplyr::ends_with("color")) %>%
dplyr::arrange(hair_color,skin_color,eye_color) -> a
starwars %>%
tidyft::setDT() %>%
tidyft::select("name|color$") %>%
tidyft::arrange(hair_color,skin_color,eye_color) -> b
})
all.equal(a,b)
rm(list = ls())
library(profvis)
library(dplyr)
library(tidyft)
as.data.frame(starwars) -> starwars
starwars[sample.int(1:nrow(starwars),1e6,replace = T),] -> starwars
copy(starwars) -> dat1
copy(starwars) -> dat2
copy(starwars) -> dat3
profvis({
a = dat1 %>%
dplyr::as_tibble() %>%
dplyr::select(name, dplyr::ends_with("color")) %>%
dplyr::arrange(hair_color,skin_color,eye_color)
b = setorder(setDT(dat2)[,.SD,.SDcols = patterns("name|color$")],
hair_color,skin_color,eye_color)
c = dat3 %>%
tidyft::setDT() %>%
tidyft::select("name|color$") %>%
tidyft::arrange(hair_color,skin_color,eye_color)
})
all.equal(a,b)
all.equal(b,c)