r - Sparktables: How can I output addition table elements? -


i have data frame (counts of faults in ms office on number of years) using generate sparktable successfully:

df_office_final_sparktable component   faults time excel       2      2001 excel       1      2002 excel       5      2003 excel       5      2004 excel       5      2005 excel       6      2006 excel       0      2007 excel       0      2008 excel       0      2009 excel       0      2010 excel       0      2011 excel       0      2012 ppt         1      2001 ppt         1      2002 ppt         1      2003 ppt         1      2004 ppt         2      2005 ppt         3      2006 ppt         0      2007 ppt         0      2008 ppt         0      2009 ppt         0      2010 ppt         0      2011 ppt         0      2012 word        5      2001 word        4      2002 word        3      2003 word        1      2004 word        3      2005 word        2      2006 word        5      2007 word        3      2008 word        0      2009 word        1      2010 word        0      2011 word        0      2012 

here corresponding code: office_content<-list(

2001=function(x) { head(x,1) }, 2012=function(x) { tail(x,1) }, office_content[['office trend']]<-newsparkline()) office_vartype<-rep("outages",3)  df_office_final_sparktable<-df_office_final_sparktable[,c("component","faults","time")]  df_office_final_sparktable$time<-as.numeric(as.character(df_office_final_sparktable$time))     office_dat<-reshapeext(df_office_final_sparktable,idvar="component",varying=list(2)) office_sparktab<-newsparktable(office_dat,office_content,office_vartype) showsparktable (office_sparktab , outputtype = "html", filename = "t1") 

can see able output table of 2001 , 2012 faults using head commands , corresponding sparkline. can't seem figure out how output fault totals 2002 - 2011 (inclusive) tried pull second row of dataframe using following code:

df_office_final_sparktable[2:2, 1:3] 

realise isn't correct there no way me map command function wondering need write 10 separate functions need call in order pull required fault totals each office component year on year?

thanks in advance, jonathan

ok figured 1 out. had create 10 functions pull 2nd row data frame so:

head_row2_office <- function(x) { result <- subset(x, time =='2002' & component =="excel", select=c(1:3)) return (result) } 

after had call functions in list function so:

office_content<-list( jan=function(x) { head(x,1) }, feb=function(x) { head_row2_office(x) }, mar=function(x) { head_row3_office(x) }, apr=function(x) { head_row4_office(x) }, may=function(x) { head_row5_office(x) }, jun=function(x) { head_row6_office(x) }, jul=function(x) { head_row7_office(x) }, aug=function(x) { head_row8_office(x) }, sep=function(x) { head_row9_office(x) }, oct=function(x) { head_row10_office(x) }, nov=function(x) { head_row11_office(x) }, dec=function(x) { tail(x,1) }, office_content[['office trend']]<-newsparkline() )  office_vartype<-rep("outages",13) # set tables columns 13 table + graph df_office_final_sparktable<-df_office_final_sparktable[,c("component","faults","time")] df_office_final_sparktable$time<-as.numeric(as.character(df_office_final_sparktable$time)) office_dat<-reshapeext(df_office_final_sparktable,idvar="component",varying=list(2)) office_sparktab<-newsparktable(office_dat,office_content,office_vartype) showsparktable (office_sparktab , outputtype = "html", filename = "t1") 


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -