-
Couldn't load subscription status.
- Fork 1k
Add select parameter to fwrite() to avoid temporary objects #7236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
1fb7294
ee3e85f
01d8bbe
9837fd4
97cb32b
4f9928a
0eb227f
8424176
d0956f3
bb8320d
8e63991
d237f57
3a718c0
23214d1
2744a89
66d3744
7f7a061
1887699
d5c933b
b0e7f82
8fe7002
2a0549f
ec25903
e54bd71
6047fa3
c2c5d89
926bb0e
cbffb5b
ea91282
28705de
94a9b59
377620e
d834811
08f6fee
b072be5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -270,14 +270,23 @@ if (requireNamespace("bit64", quietly = TRUE)) { | |
|
|
||
| ### 2.4 Column Order and Subset Control | ||
|
|
||
| To control the order and subset of columns written to file, subset the data.table before calling `fwrite()`. The `col.names` argument in `fwrite()` is a logical (TRUE/FALSE) that controls whether the header row is written, not which columns are written. | ||
| To control the order and subset of columns written to file, you can use `[.data.table` to make a new table before calling `fwrite()`, but it is more efficient to use the `select` argument, which avoids making a copy. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Mukulyadav2004 please proof-read and modify if you like. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, also I've replaced select with cols in the last line so that x remains list or data.table There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tdhock can you please guide why the error in atime even after seperating both the test cases |
||
|
|
||
| ```{r} | ||
| dt = data.table(A = 1:3, B = 4:6, C = 7:9) | ||
|
|
||
| # Write only columns C and A, in that order | ||
| fwrite(dt[, .(C, A)], "out.csv") | ||
| cat(readLines("out.csv"), sep = "\n") | ||
| fwrite(dt, "out.csv", select=c("C","A")) | ||
| cat(readLines("out.csv"), sep = "\n") | ||
| file.remove("out.csv") | ||
| ``` | ||
|
|
||
| The `col.names` argument in `fwrite()` is a logical (TRUE/FALSE) that controls whether the header row is written, not which columns are written. | ||
|
|
||
| ```{r} | ||
| fwrite(dt, "out.csv", col.names=FALSE) | ||
| cat(readLines("out.csv"), sep = "\n") | ||
| file.remove("out.csv") | ||
| ``` | ||
|
|
||
|
|
@@ -292,4 +301,4 @@ For users interested in detailed, up-to-date performance comparisons, we recomme | |
|
|
||
| These benchmarks consistently show that `fread` and `fwrite` are highly competitive and often state-of-the-art for performance in the R ecosystem. | ||
|
|
||
| *** | ||
| *** | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good idea for correctness, thanks!
but I don't think it will affect this PR, because there are no modifications to
[.data.tableUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for review! can you please guide how can I improve it then to get head constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tdhock I can't able to figure out why plot is linear at high N, its clear to me that memory plot grows with N as out test builds a 1*N table but for time graph, for most N its flat and rises at very high N - likely some overhead when N is big maybe OS or disk effect, not sure.
Could you please spare some time to explain me the likely cause so that I can work upon it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must have added some code which is linear in the number of columns. please look in the additions you made.