Skip to content

Commit 39998d6

Browse files
Add files via upload
1 parent c55b5df commit 39998d6

29 files changed

+251
-102
lines changed

CRAN-RELEASE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
This package was submitted to CRAN on 2020-04-02.
1+
This package was submitted to CRAN on 2020-04-10.
22
Once it is accepted, delete this file and tag the release (commit fbccc9581e).

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: tidyfst
22
Title: Tidy Verbs for Fast Data Manipulation
3-
Version: 0.9.4
3+
Version: 0.9.5
44
Depends: R (>= 3.3.0)
55
Authors@R:
66
person(given = "Tian-Yuan",

NAMESPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export(mutate_vars)
5555
export(mutate_when)
5656
export(nest_dt)
5757
export(nth)
58+
export(object_size)
5859
export(parse_fst)
5960
export(pull_dt)
6061
export(rbindlist)
@@ -81,8 +82,11 @@ export(slice_fst)
8182
export(squeeze_dt)
8283
export(summarise_dt)
8384
export(summarise_vars)
85+
export(summarise_when)
8486
export(summarize_dt)
8587
export(summarize_vars)
88+
export(summarize_when)
89+
export(summary_fst)
8690
export(sys_time_print)
8791
export(t_dt)
8892
export(tables)
@@ -102,3 +106,4 @@ import(fst)
102106
import(stringr)
103107
importFrom(stats,na.omit)
104108
importFrom(stats,setNames)
109+
importFrom(utils,object.size)

R/_global_setting.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @import fst
44
#' @import stringr
55
#' @importFrom stats na.omit setNames
6-
6+
#' @importFrom utils object.size
77

88
#' @export
99
stringr::`%>%`

R/complete.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,13 @@ complete_dt = function(.data,...,fill = NA){
4949
str_replace("list","CJ") %>%
5050
parse(text = .) %>%
5151
eval() %>%
52-
merge(setorder(dt),all = TRUE) %>%
52+
merge(dt,all = TRUE) %>%
53+
#merge(setorder(dt),all = TRUE) %>%
5354
replace_na_dt(to=fill) %>%
5455
unique()
5556
}else
56-
setorder(dt)%>%
57+
dt %>%
58+
#setorder(dt)%>%
5759
select_dt(...) %>%
5860
lapply(unique) %>%
5961
deparse() %>%

R/count_dt.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ count_dt = function(.data,...,sort = TRUE,.name = "n"){
3737
#' @rdname count
3838
#' @export
3939
add_count_dt = function(.data,...,.name = "n"){
40-
dt = as_dt(.data)
40+
#dt = as_dt(.data)
41+
dt = as.data.table(.data)
4142
dot_string = substitute(list(...))
4243
dt[,(.name):=.N,by = dot_string][]
4344
}

R/distinct_dt.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@
2222

2323
distinct_dt = function(.data,...,.keep_all = FALSE){
2424
dt = as_dt(.data)
25-
if(length(substitute(...)) == 0) unique(dt)
26-
else{
27-
if(.keep_all) eval(substitute(dt[,.SD[1],by = .(...)]))
28-
else eval(substitute(unique(dt[,.(...),])))
29-
}
25+
sel_name = select_dt(dt[0],...) %>% names()
26+
if(.keep_all) unique(dt,by = sel_name)
27+
else unique(dt[,.SD,.SDcols = sel_name])
3028
}
3129

32-
33-
30+
# distinct_dt = function(.data,...,.keep_all = FALSE){
31+
# dt = as_dt(.data)
32+
# if(length(substitute(...)) == 0) unique(dt)
33+
# else{
34+
# if(.keep_all) eval(substitute(dt[,.SD[1],by = .(...)]))
35+
# else eval(substitute(unique(dt[,.(...),])))
36+
# }
37+
# }
3438

3539

3640

R/dt.R

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,26 @@
1919
#' @rdname dt
2020
#' @export
2121
in_dt = function(.data,...){
22-
dt = as_dt(.data)
22+
#dt = as_dt(.data)
23+
dt = as.data.table(.data)
2324
dt[...][]
2425
}
2526

2627
#' @rdname dt
2728
#' @export
29+
30+
2831
as_dt = function (.data) {
29-
if (is.data.frame(.data) || ("fst_table" %chin% class(.data)))
32+
if(is.data.table(.data)) .data
33+
else if (is.data.frame(.data) || ("fst_table" %chin% class(.data)))
3034
as.data.table(.data)
3135
else stop("Only a data.frame or fst_table could be received.")
3236
}
37+
38+
39+
40+
# as_dt = function (.data) {
41+
# if (is.data.frame(.data) || ("fst_table" %chin% class(.data)))
42+
# as.data.table(.data)
43+
# else stop("Only a data.frame or fst_table could be received.")
44+
# }

R/dummy_dt.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
#' @export
2424
dummy_dt = function(.data,...,longname = TRUE){
25-
dt = as_dt(.data)
25+
# dt = as_dt(.data)
26+
dt = as.data.table(.data)
2627
if((substitute(list(...)) %>% deparse())=="list()")
2728
warning("No columns provided, return the orginal data.")
2829
else{

R/fst.R

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#' @param ... The filter conditions
99
#' @return \code{parse_fst} returns a fst_table class.
1010
#' @return \code{select_fst} and \code{filter_fst} returns a data.table.
11-
#' @seealso \code{\link[fst]{fst}}
11+
#' @details \code{summary_fst} could provide some basic information about
12+
#' the fst table.
13+
#' @seealso \code{\link[fst]{fst}}, \code{\link[fst]{metadata_fst}}
1214
#' @examples
1315
#'
1416
#' \dontrun{
@@ -21,6 +23,7 @@
2123
#' lapply(ft,class)
2224
#' names(ft)
2325
#' dim(ft)
26+
#' summary_fst(ft)
2427
#'
2528
#' # get the data by query
2629
#' ft %>% slice_fst(1:3)
@@ -62,12 +65,12 @@ slice_fst = function(ft,row_no){
6265

6366
#' @rdname fst
6467
#' @export
65-
select_fst = function(ft,...){
66-
67-
setDT(ft[1,])[0] %>% select_dt(...) %>% names() -> sel_names
68-
setDT(ft[names(ft) %chin% sel_names])[]
69-
70-
}
68+
# select_fst = function(ft,...){
69+
#
70+
# setDT(ft[1,])[0] %>% select_dt(...) %>% names() -> sel_names
71+
# setDT(ft[names(ft) %chin% sel_names])[]
72+
#
73+
# }
7174

7275
select_fst = function(ft,...){
7376

@@ -95,7 +98,11 @@ filter_fst = function(ft,...){
9598
eval(parse(text = str_glue("ft[{dot_string},] %>% as.data.table()")))
9699
}
97100

98-
101+
#' @rdname fst
102+
#' @export
103+
summary_fst = function(ft){
104+
metadata_fst(.subset2(ft, "meta")[[1]])
105+
}
99106

100107

101108

0 commit comments

Comments
 (0)