1

我有以下数据框:

     PD4115a PD4088a  PD4192a      
   1 ABCA8   ATRX     ADAM32      
   2 ANK2    CDH9     C11orf30
   3 ANO3    CKAP2L   CCBL2      

我想要的是一个包含所有值的列表:

     1 ABCA8 ATRX ADAM32 ANK2 CDH9 C11orf30 ANO3CKAP2L CCBL2

请帮帮我,我是R中的菜鸟。

非常感谢

4

1 回答 1

2

由于 data.frames “真的” 是一种特殊的列表,您可以使用unlist(),如下所示:

df <- data.frame(A=letters[1:3], B=letters[4:6], stringsAsFactors = FALSE)
unlist(df)
#  A1  A2  A3  B1  B2  B3 
# "a" "b" "c" "d" "e" "f" 

## To help understand why it works, here are a few ways to see the sense 
## in which data.frames are lists 
is.list(df)         # Ask R
typeof(df)          # Check the storage mode
class(unclass(df))  # Strip off the "data.frame" class attribute
于 2012-10-26T18:56:05.667 回答