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

dcast instead of SDcols #3475

Merged
merged 1 commit into from
Nov 21, 2024
Merged

dcast instead of SDcols #3475

merged 1 commit into from
Nov 21, 2024

Conversation

tdhock
Copy link
Contributor

@tdhock tdhock commented Nov 19, 2024

using dcast is simpler so you may consider mentioning that, for example below

> data.table(iris)[, unlist(lapply(.SD, function(x) c(max=max(x), min=min(x)))), .SDcols = c("Petal.Length", "Petal.Width") ]
Petal.Length.max Petal.Length.min  Petal.Width.max  Petal.Width.min 
             6.9              1.0              2.5              0.1 
> dcast(data.table(iris), . ~ ., list(max,min), value.var = c("Petal.Length", "Petal.Width"))
Key: <.>
        . Petal.Length_max Petal.Width_max Petal.Length_min Petal.Width_min
   <char>            <num>           <num>            <num>           <num>
1:      .              6.9             2.5                1             0.1

using dcast is simpler so you may consider mentioning that, for example below
```r
> data.table(iris)[, unlist(lapply(.SD, function(x) c(max=max(x), min=min(x)))), .SDcols = c("Petal.Length", "Petal.Width") ]
Petal.Length.max Petal.Length.min  Petal.Width.max  Petal.Width.min 
             6.9              1.0              2.5              0.1 
> dcast(data.table(iris), . ~ ., list(max,min), value.var = c("Petal.Length", "Petal.Width"))
Key: <.>
        . Petal.Length_max Petal.Width_max Petal.Length_min Petal.Width_min
   <char>            <num>           <num>            <num>           <num>
1:      .              6.9             2.5                1             0.1
```
@bkamins
Copy link
Member

bkamins commented Nov 19, 2024

What package does it come from?

@bkamins bkamins added the doc label Nov 19, 2024
@bkamins bkamins added this to the patch milestone Nov 19, 2024
@tdhock
Copy link
Contributor Author

tdhock commented Nov 20, 2024

it comes from data.table which I thought was obvious since it is under the section about comparison with data.table, but to emphasize that you may change dcast(...) to data.table::dcast(...)

@bkamins
Copy link
Member

bkamins commented Nov 21, 2024

The question was that I thought that dcast is not owned by data.table package, but indeed I checked the documentation and it is the way you say. Thank you!

@bkamins bkamins merged commit c27a231 into JuliaData:main Nov 21, 2024
7 of 8 checks passed
@bkamins
Copy link
Member

bkamins commented Nov 21, 2024

Thank you!

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

Successfully merging this pull request may close these issues.

2 participants