[R] Lists into matrices within lists...again
David Winsemius
dwinsemius at comcast.net
Tue Feb 23 04:28:03 CET 2010
On Feb 22, 2010, at 8:27 PM, ewaters wrote:
>
> Related questions to this have been asked before, but I have tried all
> options they gave me unsuccessfully (do.call and unlist).
>
> I start with three lists of summary statistics, 100 elements each,
> which I
> bind together:
>
None of this represents data that are too large to include in an
unambiguous fashion with dump or dput. Why do youy persist in asking
questions whare there remain ambiguities?
> statslist <- as.data.frame(cbind (means, vars, mcrs))
>
> I then take 100 samples of this data frame of varying lengths:
>
> stats <- lapply (1:100, function (dummy) {
> statslist[sample(nrow(statslist), (sample (10:20, 1, replace = TRUE)),
> replace = TRUE),]})
So what are readers supposed to do? Create similar structures and work
on them?
>
> It returns basically what I want:
>
>> stats[[i]]
> means vars mcrs
> 71 1.81 3.832222 2.92725
> 9 2.56 8.127677 4.734874
> 91 3.44 9.66303 5.24902
> 68 0.14 0.1216162 0.008686869
>
> except that:
>
>> is.list(stats[[i]]$means)
> [1] TRUE
So lapply on a list returns a list? Where is the surprise?
>
> I don't want this to be a list, because I want to do regressions
> using the
> variable which are in columns, which apparently R won't do if they
> are in
> lists.
>
> I have tried every possible combination of working with do.call,
> rbind,
> as.data.frame, etc to get this into matrix form to no avail.
>
> I have also tried using sapply instead of lapply, but that returns
> vectors
> which again, R doesn't want to do regression on.
???? R does not want to do regressions on vectors??? How can that be?
>
> Any tips would be very much appreciated, been going around in
> circles for a
> while here.
>
Reproducible data would answer these questions and prevent this
"circular" process that _you_ are responsible for allowing to continue.
--
David.
> Edward Waters
> PhD Student UNSW
>
>
> --
> View this message in context: http://n4.nabble.com/Lists-into-matrices-within-lists-again-tp1565433p1565433.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list