# 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", exact=TRUE))
# [1] "1.fst" "3.fst"
# clean up
delete(diskf)
delete(df2)
Run the code above in your browser using DataLab