0

我正在尝试使用ggpubrggtexttable中的函数创建一个可发布的表。我有一个数据框:

dput(df)    
structure(list(feature = list("start_codon", "stop_codon", "intergenic", 
        "3UTR", "5UTR", "exon", "intron", "ncRNA", "pseudogene"), 
        observed = list(structure(1L, .Names = "start_codon"), structure(1L, .Names = "stop_codon"), 
            structure(418L, .Names = "intergenic"), structure(48L, .Names = "3UTR"), 
            structure(28L, .Names = "5UTR"), structure(223L, .Names = "exon"), 
            structure(578L, .Names = "intron"), structure(20L, .Names = "ncRNA"), 
            structure(1L, .Names = "pseudogene")), expected = list(
            0.286, 0.286, 369.02, 72.461, 33.165, 257.869, 631.189, 
            48.491, 3.172), fc = list(3.5, 3.5, 1.1, 0.7, 0.8, 0.9, 
            0.9, 0.4, 0.3), test = list("enrichment", "enrichment", 
            "enrichment", "depletion", "depletion", "depletion", 
            "depletion", "depletion", "depletion"), sig = list("F", 
            "F", "T", "T", "F", "T", "T", "T", "F"), p_val = list(
            "0.249", "0.249", "0.00186", "0.00116", "0.209", "0.00814", 
            "0.00237", "<1e-04", "0.175")), class = "data.frame", row.names = c(NA, 
    -9L), .Names = c("feature", "observed", "expected", "fc", "test", 
    "sig", "p_val"))

当我试图把它变成一张桌子时:

ggtexttable(df)

我得到错误:

(function (label, parse = FALSE, col = "black", fontsize = 12, : 未使用的参数 (label.feature = dots[[5]][ 1 ], label.observed = dots[[6]][ 1 ],label.expected = 点[[7]][ 1 ],label.fc = 点[[8]][ 1 ],label.test = 点[[9]][ 1 ],label.sig_val = 点[[10]][ 1 ],label.p_val = 点[[11]][ 1 ])

有谁知道这可能是什么原因造成的?

这工作正常:

df <- head(iris)
ggtexttable(df)

在此处输入图像描述

4

1 回答 1

1

我找到了适合您的问题和解决方案。首先,您的数据格式不正确(嵌套列表),这就是您在尝试显示它时遇到此错误的原因。您可以通过在控制台中粘贴来轻松检查数据集的格式:str(data)

这是将数据转换为的解决方案data.frame

first.step <- lapply(data, unlist) 
second.step <- as.data.frame(first.step, stringsAsFactors = F) 

然后您可以轻松地使用该功能ggtexttable(second.step),它会显示包含您的数据的表格。

于 2017-08-02T12:04:59.467 回答