Skip to content
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

The new function DT() used for chaining/piping drops data.frame rownames names #5430

Open
Kamgang-B opened this issue Aug 4, 2022 · 3 comments

Comments

@Kamgang-B
Copy link
Contributor

I noticed that the new function DT() drops row names when applied to data.frame.

df = mtcars[1:5, 1:2]
df
		   mpg cyl
Mazda RX4         21.0   6
Mazda RX4 Wag     21.0   6
Datsun 710        22.8   4
Hornet 4 Drive    21.4   6
Hornet Sportabout 18.7   8

df |> 
  DT(1:4, .SD)
  
   mpg cyl
1 21.0   6
2 21.0   6
3 22.8   4
4 21.4   6
@Kamgang-B Kamgang-B changed the title The new function DT() used for chaining/piping does drops data.frame rownames names The new function DT() used for chaining/piping drops data.frame rownames names Aug 4, 2022
@ecoRoland2
Copy link

I assume that's intended. data.table doesn't support row names (for good reasons).

@Kamgang-B
Copy link
Contributor Author

Kamgang-B commented Aug 4, 2022

Maybe I was not clear enough, Note that the input here is not a data.table but a data.frame (as apposed to data.table which is its extension). DT() works with data.frame's too (not only data.tables).

I personally think that the row names should be kept too since the input and output in this case support row names, and in my example it has row names.

The reasons you refer to are likely those specific to data.table.

@Kamgang-B
Copy link
Contributor Author

Because DT() supports build-in data.frame (as opposed to data.table), I think it should also handle it appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants