You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
, so the transform function has potential to cut this short.
It has however no keep.rownames = T argument (or something similar), so the variable names disappear:
This could have been useful in this SO post -- instead of needing the helper function coefsplit to break apart the named result of coef(...), we could do transpose(as.list(coef(...)), keep.rownames = TRUE).
This comes at a sort of general thing that I run into a lot of needing to split the named result of a routine into separate columns because the names are important (most salient and consistent example being when I run table by group)
Activity
juanpide commentedon Mar 8, 2017
This should be easy to implement and an important addition.
MichaelChirico commentedon Mar 8, 2017
juanpide commentedon Mar 8, 2017
Imagine you have a data.table with several columns, such as this toy example.
dt = data.table(A=1:5, B=c(NA,3,3,NA,NA), C=c(NA,NA,9,8,7))and you want to calculate several things to summarize the different variables.
Something similar to this:
t(apply(dt,2,function(x) rbind(sum(x,na.rm = T),sum(is.na(x)))))
But I having a result with colnames and rownames:
MichaelChirico commentedon Mar 21, 2017
This could have been useful in this SO post -- instead of needing the helper function
coefsplitto break apart the named result ofcoef(...), we could dotranspose(as.list(coef(...)), keep.rownames = TRUE).This comes at a sort of general thing that I run into a lot of needing to split the named result of a routine into separate columns because the names are important (most salient and consistent example being when I run
tableby group)Closes #1886 -- keep.rownames argument for transpose