[R] format: from list to data frame
David Winsemius
dwinsemius at comcast.net
Sat Mar 13 17:56:11 CET 2010
On Mar 13, 2010, at 11:46 AM, Javier wrote:
>
> Dear users,
>
> Is anyone out there on a Saturday to answer this easy question?
>
> I have the "yo" object data in a "list" format:
>
>> str(yo)
> num [1:259, 1:173] 16.3 NA NA NA NA ...
> - attr(*, "dimnames")=List of 2
> ..$ x: chr [1:259] "367319" "367329" "367309" "367339" ...
> ..$ y: chr [1:173] "780175" "780185" "780195" "780205" ...
>> length(yo)
> [1] 44807
>
> where x is the name of the rows and y the name of the columns
> (coordinates)
> of a matrix of 44807 values
>
> how can I get a data.frame with these three columns: x, y, values
?as.data.frame.table
> as.data.frame.table(matrix((1:16)/16, ncol=2))
Var1 Var2 Freq
1 A A 0.0625
2 B A 0.1250
3 C A 0.1875
4 D A 0.2500
5 E A 0.3125
6 F A 0.3750
7 G A 0.4375
8 H A 0.5000
9 A B 0.5625
10 B B 0.6250
11 C B 0.6875
12 D B 0.7500
13 E B 0.8125
14 F B 0.8750
15 G B 0.9375
16 H B 1.0000
You will need to relabel the columns but the "names()<-" function will
suffice.
--
David.
>
> Many thanks to the Saturday working people.
>
> Javier
>
>
>
>
>
>
>
>
> and I want to produce a data frame
>
> --
> View this message in context: http://n4.nabble.com/format-from-list-to-data-frame-tp1591773p1591773.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list