[R] dbApply and data.frame

Jesper Runge Madsen runge at plan.auc.dk
Thu Jul 17 21:24:03 CEST 2003


Hallo again

I now succeeded in using dbApply on my data and I can convert it into a
data.frame. But as Peter Dalgaard pointed out I his answer to my earlier
question (Re: [R] list to data frame, 17.07.2003) I get one row and 10000
columns instead of  what I want two columns and 10000 rows when I convert
the list that dbApply returns to a Data frame.

The list I want to convert looks like this

structure(list("10000" = 123.85, "100003" = 59.7, "100004" = 61.5, 
    "100005" = 61.525, "10001" = 124.525, "100016" = 64.93848, 
    "100018" = 64.55, "10002" = 125.435, "100020" = 61.5714, 
.
.
.
    "9998" = 124.75, "99987" = 58.86503, "99989" = 61.93, "9999" = 123.8625,

    "99993" = 59.850025, "99995" = 36.853585), .Names = c("10000", 
"100003", "100004", "100005", "10001", "100016", "100018", "10002", 
.
.
"99962", "9997", "99973", "99978", "9998", "99987", "99989", 
"9999", "99993", "99995"))
 

what I get when I use as.data.frame(fraktil) is as said
 

X10000           X100003          X100004
123.85            59.7                61,5
 
I have tried this
fraktil.df <-
data.frame(LinieID=names(fraktil),"quantile_85"=unlist(fraktil))
but when I do this R shutsdown with no warning( R 1071, on a winXP system)
the same happens when I try write.table or dbWriteTable(con, "fraktil",
fraktil)
What I would like to end up with is a table like this
 
LinieID	quantile_85
100005	61.525
10001      124.525
100016     64.93848 
100018     64.55
10002      125.435
100020     61.5714
.                     .
.                     .
.                     .

Now at last my question J, is  there a way to make my list/data frame into
the table shown above. And does anybody know why R is crashing. 

Jesper Runge Madsen
Ph.D.
Trafikforskningsgruppen
Institut for Samfundsudvikling og Planlægning
Aalborg Universitet
runge at plan.auc.dk
Tel: 9635 9800




More information about the R-help mailing list