[R] list to data frame
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Thu Jul 17 00:25:17 CEST 2003
"Jesper Runge Madsen" <runge at plan.auc.dk> writes:
> Dear R helpers
> I am trying to convert a list into a data frame but when I try, I get a
> stack overflow error (Error: protect(): stack overflow). My list contains
> about 17000 rows and looks like shown at the bottom. The reason that I
> want to convert it in to a data frame is that I want to export it to a
> mysql database with the dbWriteTable function.
>
> The function that I use is
> As.data.frame(listname)
>
> I hope someone can help me
>
>
>
> Cut out from the list
> structure(list("-9.000000" = 187, "9754.000000" = 130, "9755.000000" = 129,
> "9756.000000" = 125.5, "9757.000000" = 118.1111, "9762.000000" =
> 132.6667,
> "9763.000000" = 133, "9764.000000" = 130, "9766.000000" = 130.5,
> "9780.000000" = 160, "9787.000000" = 154, "9808.000000" = 147.8,
> "9811.000000" = 156.5, "9812.000000" = 154.3333, "9815.000000" = 141,
> "9819.000000" = 135, "9820.000000" = 141, "9821.000000" = 140.5,
> .
> .
> .
> .
> "525965.000000" = 76.4545), .Names = c("-9.000000", "9754.000000",
> "9755.000000", "9756.000000", "9757.000000", "9762.000000",
> "9763.000000",
> "9764.000000", "9766.000000", "9780.000000", "9787.000000",
> "9808.000000",
> "9811.000000", "9812.000000", "9815.000000", "9819.000000",
> "9820.000000",
> "9821.000000", "9822.000000", "9823.000000", "9824.000000",
> "9825.000000",
> .
> .
> .
> .
> "525863.000000", "525866.000000", "525867.000000", "525868.000000",
> "525869.000000", "525870.000000", "525951.000000", "525952.000000",
> "525954.000000", "525962.000000", "525964.000000", "525965.000000"
> ))
>
> /Jesper Runge Madsen
> Aalborg Universitet
> Denmark
There may or may not be a bug in R, but are you sure that the list is
in the format you want? Those numeric names look suspicious and the
whole thing would be converted to a data frame with *1* row and a
helluva lot of columns... If you really have a long list of length-1
vectors, you may want to do something like
data.frame(x=unlist(l))
or perhaps
data.frame(x=unlist(l),row.names=names(l))
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list