davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
245 stars 44 forks source link

'runs' argument in spanFlexTableColumns #26

Closed eusebe closed 10 years ago

eusebe commented 10 years ago

Hi,

spanFlexTableRows has a (very usefull) runs argument for merging successive rows. I think this could be usefull to have the same argument in spanFlexTableColumns.

One user case, if someone wants to colspan the status row in this transposed table:

library( boot )
library( plyr )

data(melanoma)

melanoma$Status = c( "Melanoma", "Alive" , "Non-melanoma" )[melanoma$status]
melanoma$Gender = ifelse( melanoma$sex > 0, "Male", "Female" )
melanoma$Ulceration = ifelse( melanoma$ulcer > 0, "Present", "Absent" )

data = ddply( melanoma, .(Status, Ulceration), summarize
  , n = length( thickness )
  , Mean = mean( thickness, na.rm = T )
  , SD = sd( thickness, na.rm = T )
  , Median = median( thickness, na.rm = T )
  , Min = min( thickness, na.rm = T )
  , Max = max( thickness, na.rm = T )
  , Missing = sum( is.na( thickness ) )
)
row.names( data ) = paste( "id", 1:nrow(data) )
t(data)
           id 1       id 2       id 3       id 4       id 5           id 6          
Status     "Alive"    "Alive"    "Melanoma" "Melanoma" "Non-melanoma" "Non-melanoma"
Ulceration "Absent"   "Present"  "Absent"   "Present"  "Absent"       "Present"     
n          "92"       "42"       "16"       "41"       " 7"           " 7"          
Mean       "1.634565" "3.581190" "2.702500" "4.938780" "2.097143"     "5.338571"    
SD         "1.927020" "2.577971" "3.349646" "3.497797" "1.928486"     "4.327511"    
Median     "1.13"     "3.06"     "1.94"     "4.04"     "1.45"         "4.84"        
Min        "0.10"     "0.32"     "0.32"     "0.97"     "0.65"         "0.16"        
Max        "12.88"    "12.24"    "14.66"    "17.42"    " 6.12"        "12.56"       
Missing    "0"        "0"        "0"        "0"        "0"            "0"    
davidgohel commented 10 years ago

Hi,

Agree with that. It should not be hard, I will code it in the following version.

Thanks for the suggestion.

David

eusebe commented 10 years ago

Thanks!

davidgohel commented 10 years ago

Hi,

It's on github.

David

eusebe commented 10 years ago

and it works perfectly. Thanks again.