-
Notifications
You must be signed in to change notification settings - Fork 985
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
fwrite substitutes class integer rownames by 1,2,3... #4957
Comments
It may be related to this: Line 262 in 1eadb95
|
Thanks for the report. Interestingly, R stores the numeric, non-integer row names as characters: DF = data.frame(x = 1)
## integer storage
rownames(DF) = 1L
class(attributes(DF)$row.names)
#> [1] "integer"
## numeric actually stored as character!!
rownames(DF) = 1
class(attributes(DF)$row.names)
#> [1] "character" Some options to change behavior:
The first option seems good enough - I will work on a PR. It will be OK if the maintainers would prefer a different option as this should be pretty straightforward. Changes to implement option 3:Need to switch on type of rowNames so another arg may be needed. Meaning, if it is an integer row name, we need the maximum row name value to convert to character length. Lines 641 to 644 in 831013a
Other change - need to Lines 875 to 883 in 831013a
|
#
Minimal reproducible example
The following R code:
generates two output files, whose content is shown below:
out_fwrite
out_wt
I noticed
fwrite
is converting the actual rownames (i.e. 10, 20, 30) to 1, 2, 3 without warning. This does not happen whenrownames(df) <- as.numeric(c(10, 20, 30))
orrownames(df) <- as.character(c(10, 20, 30))
. This is also different from the behaviour ofwrite.table
.#
Output of sessionInfo()
The text was updated successfully, but these errors were encountered: