"Tom McCallum" <[EMAIL PROTECTED]> writes: > After getting one list done, I am now struggling to form a data frame in C. > > I tried to do a list of lists which gives me : > > $<NA> > $<NA>[[1]] > [1] "BID" > > $<NA>[[2]] > [1] 0.6718 [snip] > > and then as.data.frame them in R but this gives me
One approach is to return a named list and then turn that into a data.frame like: ret <- .Call("yourFunc", ...) attr(ret, "row.names") <- as.integer(indx) class(ret) <- "data.frame" In C, you need to create a list (VECSXP) and a character vector (STRSXP) for the names and then put the names on the list. PROTECT(ret = allocVector(VECSXP, N)); PROTECT(retnames = allocVector(STRSXP, N)); /* fill list and names */ SET_NAMES(ret, retnames); + seth ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel