Learn R Programming

disk.frame (version 0.1.0)

add_chunk: Add a chunk to the disk.frame

Description

Add a chunk to the disk.frame

Usage

add_chunk(df, chunk, chunk_id = NULL, full.names = FALSE)

Arguments

df

the disk.frame to add a chunk to

chunk

a data.frame to be added as a chunk

chunk_id

a numeric number indicating the id of the chunk. If NULL it will be set to the largest chunk_id + 1

full.names

whether the chunk_id name match should be to the full file path not just the file name

Value

disk.frame

Examples

Run this code
# NOT RUN {
# create a disk.frame
df_path = file.path(tempdir(), "tmp_add_chunk")
diskf = disk.frame(df_path)

# add a chunk to diskf
add_chunk(diskf, cars)
add_chunk(diskf, cars)

nchunks(diskf) # 2

df2 = disk.frame(file.path(tempdir(), "tmp_add_chunk2"))

# add chunks by specifying the chunk_id number; this is especially useful if
# you wish to add multiple chunk in parralel

add_chunk(df2, data.frame(chunk=1), 1)
add_chunk(df2, data.frame(chunk=2), 3)

nchunks(df2) # 2

dir(attr(df2, "path"))
# [1] "1.fst" "3.fst"

# clean up
delete(diskf)
delete(df2)
# }

Run the code above in your browser using DataLab