[R] list to dataframe
David Winsemius
dwinsemius at comcast.net
Wed May 22 22:00:50 CEST 2013
On May 22, 2013, at 5:00 AM, catalin roibu wrote:
> Hello all!
> I have a problem to transform this list in a data frame. I try
> this command as.data.frame, but unsuccessfully.
> Please help me!
>
> thank you very much!
>
> structure(list(fns = list(structure(list(r = c(0, 0.048828125,
> 0.09765625, 0.146484375, 0.1953125, 0.244140625, 0.29296875,
snipped
> 24.21875, 24.267578125, 24.31640625, 24.365234375, 24.4140625,
> 24.462890625, 24.51171875, 24.560546875, 24.609375, 24.658203125,
> 24.70703125, 24.755859375, 24.8046875, 24.853515625, 24.90234375,
> 24.951171875, 25), obs = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
> 1.93180720564088,
> 1.93180720564088, 1.93180720564088, 1.93180720564088, 3.38066260987153,
> 3.38066260987153, 3.38066260987153, 3.38066260987153, 3.38066260987153,
> 3.38066260987153, 3.86361441128175, 3.86361441128175, 6.40978511719555,
>
snipped
> 1962.78756403501, 1967.49628542858, 1979.63654508471, 1984.13520217191,
> 1985.32172929701, 1996.57852109221, 1999.18362637229, 2000.74603993057,
> 2010.39215037293), theo = c(0, 0.00749014056584786, 0.0299605622633914,
> 0.0674112650926307, 0.119842249053566, 0.187253514146196,
> 0.269645060370523,
> 0.367016887726545, 0.479368996214263, 0.606701385833676, 0.749014056584786,
> 0.906307008467591, 1.07858024148209, 1.26583375562829, 1.46806755090618,
> 1.68528162731577, 1.91747598485705, 2.16465062353003, 2.42680554333471,
> 2.70394074427108, 2.99605622633914, 3.30315198953891, 3.62522803387036,
>
snipped
> 1925.33314231063, 1932.93563498496, 1940.55310794043, 1948.18556117703,
> 1955.83299469476, 1963.49540849362), lo = c(0, 0, 0, 0, 0, 0,
> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.430663221360896,
> 0.430663221360896, 1.29198966408269, 1.29198966408269, 2.13663800010683,
> 2.4147590070511, 2.4147590070511, 2.4147590070511, 2.4147590070511,
> 2.4147590070511, 2.89771080846132, 2.89771080846132, 3.86361441128175,
> 4.30663221360896, 5.59862187769165, 5.59862187769165, 6.02928509905254,
snipped
> 1942.55643065679, 1949.40185695685, 1959.32740404899, 1960.83934002238,
> 1968.9326486939, 1973.11534382071, 1980.88232018773, 1989.06497524482,
> 1996.62818284959, 2004.07175380015, 2013.95117889312, 2020.21271152236,
> 2027.759917824, 2037.53944213567, 2043.89566188237, 2050.43346540732,
> 2060.12956056552, 2066.48377846249, 2074.40270540076, 2079.58402320784
> )), .Names = c("r", "obs", "theo", "lo", "hi"), row.names = c(NA,
> -513L), class = c("envelope", "fv", "data.frame"), argu = "r", valu =
> "obs", ylab = quote(K(r)), yexp = quote(K(r)), fmla = ". ~ r", alim = c(0,
> 25), labl = c("r", "%s[obs](r)", "%s[theo](r)", "%s[lo](r)",
> "%s[hi](r)"), desc = c("distance argument r", "observed value of %s for
> data pattern",
> "theoretical value of %s for CSR", "lower pointwise envelope of %s from
> simulations",
> "upper pointwise envelope of %s from simulations"), units = structure(list(
> singular = "unit", plural = "units", multiplier = 1), .Names =
> c("singular",
> "plural", "multiplier"), class = "units"), fname = "K", dotnames = c("obs",
> "theo", "hi", "lo"), einfo = structure(list(call =
> "envelope.ppp(list(window = list(type = \"rectangle\", xrange = c(0, ",
> Yname = "df1", valname = "iso", csr = TRUE, csr.theo = TRUE,
> pois = TRUE, simtype = "list", nrank = 1, nsim = 100, Nsim = 100,
> global = FALSE, dual = FALSE, nsim2 = 100, VARIANCE = FALSE,
> nSD = 2, do.pwrong = FALSE), .Names = c("call", "Yname",
> "valname", "csr", "csr.theo", "pois", "simtype", "nrank", "nsim",
> "Nsim", "global", "dual", "nsim2", "VARIANCE", "nSD", "do.pwrong"
> )), simpatterns = structure(list(structure(list(window = structure(list(
> type = "rectangle", xrange = c(0, 100), yrange = c(0, 100
> ), units = structure(list(singular = "unit", plural = "units",
> multiplier = 1), .Names = c("singular", "plural", "multiplier"
> ), class = "units")), .Names = c("type", "xrange", "yrange",
> "units"), class = "owin"), n = 208L, x = c(47.9617641307414,
> 36.1878849100322, 66.6270701680332, 14.2456598114222, 0.0497943023219705,
> 68.8695851247758, 16.7923918459564, 75.1742686377838, 76.2108164606616,
> 14.4676979864016, 71.2474888656288, 49.7712135082111, 94.3738523870707,
> 60.3261381387711, 30.1429545041174, 55.0198875833303, 48.9881716202945,
> 19.3922231905162, 73.3359995298088, 22.1154987346381, 73.0558406561613,
> 7.06873328890651, 16.0532583249733, 28.3029817510396, 10.5695691192523,
> 47.4329188466072, 62.3007351765409, 18.9154457533732, 41.0695919767022,
snipped
> 80.2932610735297, 22.4639500956982, 59.8186427727342, 33.3587406203151,
> 15.3955666813999, 96.026076329872, 66.4048640290275, 37.6895662629977,
> 36.7896907730028, 37.1635934803635, 80.7565903291106), y =
> c(47.5609118351713,
> 92.435561819002, 32.162977498956, 16.9752907939255, 97.0836103428155,
> 4.52358282636851, 85.9631503000855, 60.7976095983759, 95.5500576877967,
> 84.6405684482306, 68.2213885011151, 32.6724353712052, 29.8417059704661,
> 12.2012654552236, 98.7017400562763, 99.0454517770559, 71.8697892734781,
snipped
> 45.737622003071, 28.577046468854, 72.513389820233, 65.9691113280132,
> 27.5719294091687, 62.9900835687295, 10.9844085993245, 88.9378556748852,
> 86.4743151701987, 90.6967400340363, 90.8443599939346), markformat =
> "none"), .Names = c("window",
> "n", "x", "y", "markformat"), class = "ppp"), structure(list(
> window = structure(list(type = "rectangle", xrange = c(0,
> 100), yrange = c(0, 100), units = structure(list(singular = "unit",
> plural = "units", multiplier = 1), .Names = c("singular",
> "plural", "multiplier"), class = "units")), .Names = c("type",
> "xrange", "yrange", "units"), class = "owin"), n = 203L,
> x = c(16.9092988828197, 51.9989501917735, 73.7480747979134,
> 34.4980020308867, 33.2081566797569, 85.7431603129953, 69.9098466895521,
> 14.496394013986, 65.9055542899296, 43.1827196385711, 65.9691080218181,
> 77.2850989596918, 96.623027510941, 73.3569069299847, 53.5423814319074,
large amount of snipping
> 97.5, 98, 97.5, 87, 92.5, 92.5, 96, 89, 89, 93.5, 79, 97.5,
> 82, 80.5, 82, 85, 95, 97.5, 86.5, 91, 85, 92.5, 99, 97, 99.5,
> 98, 98, 97.5, 96, 99.9, 28, 39, 48.5, 51, 55, 57.5, 57, 67.5
> ), markformat = "none"), .Names = c("window", "n", "x", "y",
> "markformat"), class = "ppp"))), which = structure(1, .Dim = c(1L,
> 1L), .Dimnames = list("", "")), default.formula = NULL, dataname = "df1",
> title = "envelopes of Kest function for df1."), .Names = c("fns",
> "which", "default.formula", "dataname", "title"), class = "gasp"
I think the class of that huge irregular object is very aptly named … "gasp". It seems pretty clear why as.data.frame fails. It is simply too complex and irregular. Dataframes need to have all of their list columns of the same length.
> )
>
>
> --
> ---
> Catalin-Constantin ROIBU
> Lecturer PhD, Forestry engineer
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list