2012-10-26 72 views

回答

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 
相關問題