0

我已经创建了用于计算的数据框的子集。我现在留下了许多我想合并为一列的子集。子集如下所示:

> E
$`1`
 [1] "AAAaaa" "TTTaaa" "CCCaaa" "GGGaaa" "AAAttt" "TTTttt" "CCCttt" "GGGttt"
 [9] "AAAccc" "TTTccc" "CCCccc" "GGGccc" "AAAggg" "TTTggg" "CCCggg" "GGGggg"

$`2`
 [1] "ATAata" "TATata" "CGCata" "GCGata" "BBBata" "ATAtat" "TATtat" "CGCtat"
 [9] "GCGtat" "BBBtat" "ATAcgc" "TATcgc" "CGCcgc" "GCGcgc" "BBBcgc" "ATAgcg"
[17] "TATgcg" "CGCgcg" "GCGgcg" "BBBgcg" "ATAbbb" "TATbbb" "CGCbbb" "GCGbbb"
[25] "BBBbbb"

我试过了:

A=vector()
cbind(A,ExonJunction,deparse.level = 1)
A

但这让我有了

  E
1 Character,16
2 Character,25

我想要一列中的字符列表。我该怎么做呢?

4

3 回答 3

2

也可以尝试函数recursive中的参数c,例如

c(E, recursive = TRUE, use.names = FALSE)
#  [1] "AAAaaa" "TTTaaa" "CCCaaa" "GGGaaa" "AAAttt" "TTTttt" "CCCttt" "GGGttt" "AAAccc" "TTTccc" "CCCccc" "GGGccc" "AAAggg" "TTTggg" "CCCggg" "GGGggg" "ATAata"
# [18] "TATata" "CGCata" "GCGata" "BBBata" "ATAtat" "TATtat" "CGCtat" "GCGtat" "BBBtat" "ATAcgc" "TATcgc" "CGCcgc" "GCGcgc" "BBBcgc" "ATAgcg" "TATgcg" "CGCgcg"
# [35] "GCGgcg" "BBBgcg" "ATAbbb" "TATbbb" "CGCbbb" "GCGbbb" "BBBbbb"

或者,如果您希望它作为数据框中的一列,可以尝试

df <- data.frame(Res = c(E, recursive = TRUE))
于 2014-11-27T09:10:53.630 回答
1

您可以unlist创建list一个单列数据框data.frame

dat <- data.frame(Col1=unlist(E, use.names=FALSE), stringsAsFactors=FALSE)

数据

E <-  structure(list(`1` = c("AAAaaa", "TTTaaa", "CCCaaa", "GGGaaa", 
"AAAttt", "TTTttt", "CCCttt", "GGGttt", "AAAccc", "TTTccc", "CCCccc", 
"GGGccc", "AAAggg", "TTTggg", "CCCggg", "GGGggg"), `2` = c("ATAata", 
"TATata", "CGCata", "GCGata", "BBBata", "ATAtat", "TATtat", "CGCtat", 
"GCGtat", "BBBtat", "ATAcgc", "TATcgc", "CGCcgc", "GCGcgc", "BBBcgc", 
"ATAgcg", "TATgcg", "CGCgcg", "GCGgcg", "BBBgcg", "ATAbbb", "TATbbb", 
"CGCbbb", "GCGbbb", "BBBbbb")), .Names = c("1", "2"))
于 2014-11-27T08:39:57.013 回答
1

您也可以stack像这样使用 (假设您正在处理一个命名列表,就像您一样):

stack(E)

一个不错的功能是名称成为“ind”列,因此该过程很容易逆转。

head(stack(E))
#   values ind
# 1 AAAaaa   1
# 2 TTTaaa   1
# 3 CCCaaa   1
# 4 GGGaaa   1
# 5 AAAttt   1
# 6 TTTttt   1
tail(stack(E))
#    values ind
# 36 BBBgcg   2
# 37 ATAbbb   2
# 38 TATbbb   2
# 39 CGCbbb   2
# 40 GCGbbb   2
# 41 BBBbbb   2
于 2014-11-27T18:14:26.900 回答