-
Notifications
You must be signed in to change notification settings - Fork 2
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
How do you use capture_melt_multiple in this example? #18
Comments
Actually the syntax is good but "missing input columns" is not yet supported, I'm waiting for data table to merge my PR, see #12 > remotes::install_github(c("Rdatatable/data.table@fix4027", "tdhock/nc@multiple-fill"))
Skipping install of 'data.table' from a github remote, the SHA1 (854f1897) has not changed since last install.
Use `force = TRUE` to force installation
Skipping install of 'nc' from a github remote, the SHA1 (bbc49eca) has not changed since last install.
Use `force = TRUE` to force installation
> nc::capture_melt_multiple(DT, column=".*","_", dim=".*", fill=TRUE)
ID Zaa Zab Zba Zbb dim aa ab ba bb
1: 1 z z z z 2001 0.7256901 0.7256901 0.7256901 0.7256901
2: 2 p p p p 2001 0.4719875 0.4719875 0.4719875 0.4719875
3: 3 b b b b 2001 0.4384963 0.4384963 0.4384963 0.4384963
4: 4 u u u u 2001 0.9501824 0.9501824 0.9501824 0.9501824
5: 5 o o o o 2001 0.3648079 0.3648079 0.3648079 0.3648079
6: 1 z z z z 2002 NA 0.7256901 NA 0.7256901
7: 2 p p p p 2002 NA 0.4719875 NA 0.4719875
8: 3 b b b b 2002 NA 0.4384963 NA 0.4384963
9: 4 u u u u 2002 NA 0.9501824 NA 0.9501824
10: 5 o o o o 2002 NA 0.3648079 NA 0.3648079
> nc::capture_melt_multiple(DT, column=".*","_", dim=".*", fill=FALSE)
Error in (function (subject.names, match.dt, no.match, fill = TRUE) :
need dim=same count for each value, but have: 2001=4 2002=2; please change pattern, edit input column names, or use fill=TRUE to output missing values |
Also I did some benchmarks as well, varying the number of rows/columns, see Figures 4 and 5 in https://raw.githubusercontent.com/tdhock/nc-article/master/RJwrapper.pdf |
I need to convert from wide format to long format large datasets like this one I show in a toy example:
If I want to do it with melt and dcast I would use this:
But I can't find the proper syntax with capture_melt_multiple.
I have tried different options such as capture_melt_multiple(DT, column=".*","_", dim=".*", fill=TRUE) and also using field. But I'm always getting errors.
My intention later is to benchmark this tool in order to find the fastest way to convert wide to long for large nn, for example nn=25, and nid=10000.
The text was updated successfully, but these errors were encountered: