https://github.com/edwindj/ffbase2
dplyr for ff
https://github.com/edwindj/ffbase2
Last synced: about 1 year ago
JSON representation
dplyr for ff
- Host: GitHub
- URL: https://github.com/edwindj/ffbase2
- Owner: edwindj
- Created: 2014-08-11T13:41:29.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-08-31T08:48:07.000Z (almost 9 years ago)
- Last Synced: 2025-03-31T15:27:21.567Z (about 1 year ago)
- Language: R
- Homepage:
- Size: 72.3 KB
- Stars: 36
- Watchers: 7
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
ffbase2
=======
Next version of `ffbase`
- dplyr on ff
Working, but documentation is not yet CRAN ready...
[](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)
```