Skip to content

Create a disk.frame containing only specified columns #338

Answered by xiaodaigh
lucazav asked this question in Q&A
Discussion options

You must be logged in to vote

You can already do that since {disk.frame} uses {data.table}'s fread which provides the select= option

library(disk.frame)
#setup_disk.frame() # omitted since the data is tiny

# write the iris dataset to csv
data.table::fwrite(iris, "iris.csv")

# read only the Species and Sepal.Length columns via `select = `
iris.df = disk.frame::csv_to_disk.frame("iris.csv", select = c("Species", "Sepal.Length"))


collect(iris.df)

# Species Sepal.Length
# 1:    setosa          5.1
# 2:    setosa          4.9
# 3:    setosa          4.7
# 4:    setosa          4.6
# 5:    setosa          5.0
# ---                       
#   146: virginica          6.7
# 147: virginica          6.3
# 148: virginica    …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lucazav
Comment options

Answer selected by lucazav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #337 on May 03, 2021 00:06.