Jesper Runge Madsen wrote:
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

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


If your list were formatted like this one
>list("ColId1"=c(12,13,14),"ColId2"=c(34,56,78))->k
then
>as.data.frame(k)->g
would give desirable result
> as.data.frame(k)
a b
1 12 34
2 13 56
3 14 78
If it is related to the question you have asked earlier and you want to convert matrix back to data.frame
> k<-cbind(c(1,2,3,4),c(1,2,3,4))
> k
[,1] [,2]
[1,] 1 1
[2,] 2 2
[3,] 3 3
[4,] 4 4
> class(k)
[1] "matrix"
> as.data.frame(k)->k2
> names(k2)<-c("ColId1","ColId2")
to insert suitable column names instead default ones
> k2
ColId1 ColId2
1 1 1
2 2 2
3 3 3
4 4 4
> class(k2)
[1] "data.frame"


______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to