Skip to content
Prev 334464 / 398506 Next

why as.vector can't make x to be a vector?

According to the documentation (?as.vector), "All attributes are removed from the result if it is of an atomic mode, but not in general for a list result."

data.frames are lists so
[1] FALSE

However if you convert using unlist() or as.matrix(), you will get a vector:
[1] TRUE
[1] TRUE


-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352




-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Duncan Murdoch
Sent: Sunday, December 15, 2013 6:12 AM
To: ????; r-help
Subject: Re: [R] why as.vector can't make x to be a vector?
On 13-12-15 6:48 AM, ???? wrote:
Data frames are lists, which are already vectors.

Duncan Murdoch

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.