代码之家  ›  专栏  ›  技术社区  ›  user1631306

电源点已使用军官损坏[关闭]

  •  1
  • user1631306  · 技术社区  · 7 年前

    library(data.table)
    library(RMySQL)
    library(officer) #from source
    library(magrittr)
    library(flextable)
    library(RColorBrewer)
    library(ggplot2)
    
    tmrank.ft <- regulartable(data = tm.rank.out) %>% 
        theme_booktabs() %>% 
        autofit() %>%
        merge_v(j=missing_species) %>%
        align(align = 'center') %>%
        align(align = 'center', part = 'header') %>% 
        bold(part = 'header') %>%
        height(height = 1, part = 'header') %>% 
        fontsize(size = 14, part = 'all') %>% 
        width(j=1, width = 1.0 ) %>%
        width(j=2:ncol(tm.rank.out), width = 2.5) %>%
        (
          function(x) {
            ## These for loop causes the issue. If I dont use for loop, it works great.
            for (ii in 2:length(species)) {
              group_result <- group_vector( tm.rank.out.temp, grp.type, 'human')
              if(length(group_result) >0) {
                for (jj in 1:length(group_result)) {
                  text_color <- grp.clr[names(group_result)[jj]]
                  color(x, i = group_result[[jj]], j = ~ human, color = text_color) 
                  }
               }
             }
           }
         )
    

    数据就像

    dput(head(tm.rank.out))
    

    结构(列表(秩=1:6,人=c(“AoEC(2.1)”,“LSEC(2.1)”, “LMVEC(2)”,“前列腺(2)”,“反式淋巴细胞(2)”,“甲状腺(2)” ),cyno=c(“AoEC(2.2)”,“DR神经节(2.2)”,“肾脏(2.2)”, “LMVEC(2.2)”,“视网膜(2.2)”,“胆囊(2.1)”,狗=c(“DR神经节(2.6)”, "纹状体(2.6),"骨髓(2.5),"NAc(2.5),"肾上腺(2.5),, “盲肠(2.5)”),sorted=“秩”,class=c(“数据表”,“数据框” ),row.names=c(NA,-6L),.internal.selfref=)

    dput(head(tm.rank.out.temp))
    

    “LSEC”、“LMVEC”、“前列腺”、“反式淋巴细胞”、“甲状腺”), cyno=c(“AoEC”、“DR神经节”、“肾脏”、“LMVEC”、“视网膜”, “胆囊”,狗=c(“神经节”、“纹状体”、“骨髓”), “NAc”、“肾上腺”、“盲肠”)),class=c(“数据表”、“数据框”

    1 回复  |  直到 7 年前
        1
  •  0
  •   user1631306    7 年前

    tmrank.ft <- regulartable(data = tm.rank.out) %>% 
    theme_booktabs() %>% 
    autofit() %>%
    merge_v(j=missing_species) %>%
    align(align = 'center') %>%
    align(align = 'center', part = 'header') %>% 
    bold(part = 'header') %>%
    height(height = 1, part = 'header') %>% 
    fontsize(size = 14, part = 'all') %>% 
    width(j=1, width = 1.0 ) %>%
    width(j=2:ncol(tm.rank.out), width = 2.5) %>%
    (
      function(x) {
        ## These for loop causes the issue. If I dont use for loop, it works great.
        for (ii in 2:length(species)) {
          group_result <- group_vector( tm.rank.out.temp, grp.type, 'human')
          if(length(group_result) >0) {
            for (jj in 1:length(group_result)) {
              text_color <- grp.clr[names(group_result)[jj]]
              color(x, i = group_result[[jj]], j = ~ human, color = text_color) 
              }
           }
         }
        x
       }
     )
    
    推荐文章