r - dcast with empty left-hand side in formula -
i'm having problems using dcast
withoud "id" variables. expected result transposition -- creating 1-row data frame many columns there rows in original data frame.
i've tried different approaches, "hacks" seem work now. before filing bug, wanted double-check if i'm missing something.
d <- data.frame(variable=letters[1:3], value=1:3) d ## variable value ## 1 1 ## 2 b 2 ## 3 c 3 reshape2::dcast(d, ...~variable) ## . b c ## 1 . 1 2 3 reshape2::dcast(d, .~variable) ## . b c ## 1 . 1 2 3 reshape2::dcast(d, ~variable) ## error: subscript out of bounds reshape2::dcast(d, 0~variable) ## 0 b c ## 1 0 1 2 3 sessioninfo() ## r version 3.1.1 (2014-07-10) ## platform: x86_64-pc-linux-gnu (64-bit) ## ## locale: ## [1] lc_ctype=en_us.utf-8 lc_numeric=c ## [3] lc_time=en_us.utf-8 lc_collate=en_us.utf-8 ## [5] lc_monetary=en_us.utf-8 lc_messages=en_us.utf-8 ## [7] lc_paper=en_us.utf-8 lc_name=c ## [9] lc_address=c lc_telephone=c ## [11] lc_measurement=en_us.utf-8 lc_identification=c ## ## attached base packages: ## [1] stats graphics grdevices utils datasets base ## ## loaded via namespace (and not attached): ## [1] evaluate_0.5.6 formatr_1.0 knitr_1.6.18 methods_3.1.1 ## [5] plyr_1.8.1 rcpp_0.11.2 reshape2_1.4 stringr_0.6.2 ## [9] tools_3.1.1 ulimit_0.0-2
what doing wrong? why dcast
creating odd , useless .
column when using ...~variable
or .~variable
formula?
Comments
Post a Comment