[R] data.frame() creates list?
Bill.Venables at csiro.au
Bill.Venables at csiro.au
Thu Aug 21 03:15:08 CEST 2008
Data frames *are* lists. They just have a guaranteed structure and a
different class, but they may be used interchangably with lists nearly
everywhere.
Try
class(ByEBNum)
for a more relevant check of what kind of object you have.
Bill Venables
http://www.cmis.csiro.au/bill.venables/
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of Farley, Robert
Sent: Thursday, 21 August 2008 10:34 AM
To: r-help at r-project.org
Subject: [R] data.frame() creates list?
I obviously don't know what I'm doing. I want to create "ByEBNum" as a
data frame, but it comes out as a list. How do I make it a data frame?
> EBNumStn <- c(673.65, 800, 1000, 1000, 800, 700, 600, 500, 400,
200, 50, 50 )
> ByEBNum <- data.frame(c(1:12),EBNumStn)
> typeof(EBNumStn)
[1] "double"
> typeof(c(1:12))
[1] "integer"
> typeof(ByEBNum)
[1] "list"
> ByEBNum
c.1.12. EBNumStn
1 1 673.65
2 2 800.00
3 3 1000.00
4 4 1000.00
5 5 800.00
6 6 700.00
7 7 600.00
8 8 500.00
9 9 400.00
10 10 200.00
11 11 50.00
12 12 50.00
>
>sessionInfo()
R version 2.7.1 (2008-06-23)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] graphics grDevices utils datasets stats methods base
other attached packages:
[1] survey_3.8 fortunes_1.3-5 moonsun_0.1 prettyR_1.3-2
foreign_0.8-28
>
Robert Farley
Metro
1 Gateway Plaza
Mail Stop 99-23-7
Los Angeles, CA 90012-2952
Voice: (213)922-2532
Fax: (213)922-2868
www.Metro.net
[[alternative HTML version deleted]]
______________________________________________
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.
More information about the R-help
mailing list