我有一个数据结构,其中rownames是基因的名称(示例数据集位于底部)。但是,并非所有名称都是已知的。在这种情况下,rowname是X.,所以X.1,X.2,X.3等。我想计算我的数据集中有多少没有名称的基因,所以计算所有的X.值。
我如何计算类似的rownames?
structure(c(3.98955, 4.34032, 4.84637, 4.18783, 4.03547, 4.28602,
3.85645, 4.26538, 4.67382, 4.15131, 4.03988, 4.35458, 3.91201,
4.0837, 4.53863, 4.06491, 4.05978, 4.53879, 11.5801, 11.2286,
11.2579, 10.5792, 9.98419, 10.6074, 11.7636, 10.9253, 10.9952,
10.2337, 9.51475, 10.0747, 10.5695, 10.9376, 11.4955, 10.3862,
10.0824, 9.1608), .Dim = c(6L, 6L), .Dimnames = list(c("X.9",
"X34k", "lers", "afaf", "X.12", "X.3434"), c("Sham3.r1",
"Sham3.r2", "Sham3.r3", "T00d4h.r2", "T00d4h.r3", "T00d4h.r4"
)))
答案 0 :(得分:1)
您可以使用grep
:
length(grep("X.", rownames(DF), fixed=TRUE))
#[1] 3