Conversation
Include row.names from R
…e number at the end of the first sentence)
mattdowle
reviewed
Aug 10, 2021
| nThread = as.integer(nThread) | ||
| # write.csv default is 'double' so fwrite follows suit. write.table's default is 'escape' | ||
| # validate arguments | ||
| rn = if (row.names) row.names(x) else NULL # allocate row.names in R to address integer row.names #4957 |
Member
There was a problem hiding this comment.
I like your reasoning for this; i.e. option 1 you detailed in issue. However I'm just a bit concerned about any inadvertent usage that ends up somehow calling row.names=TRUE without the user intending to. Then 1:nrow will be coerced to character by this line and the global character cache gets clobbered. Would prefer not to leave that door open. Another door open would be benchmarkers who either deliberately or by accident display results with row.names = TRUE and show poor performance.
Hence I went for option 3 as you described.
Contributor
Author
There was a problem hiding this comment.
Brilliant! Thanks for your time - changes look great!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4957 .
The biggest change is behavior of
quote = autofor default row names and for integer assigned row-names because this PR makes all row names characters.I believe this better matches existing behavior with
quote = 'auto'as the current behavior will not add double quotes to character row.names:Finally, based on this PR, this part of
fwrite.cshown below is no longer used. In the issue, I comment about how to do this more directly in C. I would be happy to move forward with a C approach but it just seems like a higher diff for little productivity. While maybe big data people who need performance use row names, overall I doubt it.data.table/src/fwrite.c
Lines 876 to 881 in 831013a