-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.Rmd
81 lines (63 loc) · 1.64 KB
/
README.Rmd
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
ffbase2
=======
Next version of `ffbase`
- dplyr on ff
Working, but documentation is not yet CRAN ready...
[![Build Status](https://travis-ci.org/edwindj/ffbase2.svg?branch=master)](https://travis-ci.org/edwindj/ffbase2)
## Install
`ffbase` is currently only available from github. To install it, run the following
script.
```S
# install.packages("devtools")
devtools::install_github("edwindj/ffbase2")
```
### CRAN-readiness
- Documentation needs to be completed
- Add more tests
- copy some `dplyr` internal functions into ffbase2
- Phase out dependency on `ffbase` (version 1)
## Usage
```{r, echo=FALSE}
library(ffbase2)
unlink("db_ff", recursive = T, force = T)
```
Creating a tbl_ffdf: this will create/use a temporary ffdf data.frame in
`options("fftempdir")`.
```S
iris_f <- tbl_ffdf(iris)
species <-
iris_f %>%
group_by(Species) %>%
summarise(petal_width = sum(Petal.Width))
```
A `tbl_ffdf` is also a `ffdf`
```{r}
iris_f <- tbl_ffdf(iris)
is.ffdf(iris_f)
```
Use `src_ffdf` for storing your data in a directory
```{r}
library(ffbase2)
# store a ffdf data.frame in "./db_ff"" directory
cars <- tbl_ffdf(mtcars, src="./db_ff", name="cars")
print(cars, n=2)
```
To retrieve tables from a ffdf source, use `src_ffdf`
```{r}
src <- src_ffdf("./db_ff")
print(src)
# what tables are available?
src_tbls(src)
#retrieve table from src
cars <- tbl(src, from="cars") # or equivalently tbl_ffdf(src=src, name="cars")
print(cars, n=2)
```
Use `copy_to` to add data to a `src_ffdf`
```{r}
src <- src_ffdf("./db_ff")
copy_to(src, iris) # or equivalenty tbl_ffdf(iris, src)
src_tbls(src)
```
```{r, echo=FALSE}
unlink("db_ff",recursive = T, force = T)
```