try this,
do.call(rbind, resample2)
#or simply,
replicate(1000, Cusum(sample(lambs,replace=F)))
you could also look at the plyr package.
Hope this helps,
baptiste
On 10 Apr 2009, at 09:03, Melissa2k9 wrote:
Hi,
I have used this command :
resamples<-lapply(1:1000,function(i) sample(lambs,replace=F))
resamples2<-lapply(resamples,Cusum)
to get a list of 1000 samples of my data. The function Cumsum is
defined as
follows:
Cusum<-function(x){
SUM<-cumsum(x)-(1:length(x))*mean(x)
min<-min(cumsum(x)-(1:length(x))*mean(x))
max<-max(cumsum(x)-(1:length(x))*mean(x))
diff<-max-min
ans<-c(min,max,diff)
ans
}
where lambs is a vector of temperatures.
An example of part of my list is:
[[998]]
[1] -5.233176 6.903034 12.136210
[[999]]
[1] -9.296690 1.516233 10.812922
[[1000]]
[1] -1.502066e+01 -4.547474e-13 1.502066e+01
Now I want to convert this list into a dataframe so for example 1000
rows
with col names Min, Max and Diff. My supervisor said I first had to
turn
this into a vector but I don't seem to be able to do that!
Any ideas on how to turn this list into a dataframe would be really
appreciated :) Thanks in advance
Melissa
--
View this message in context:
http://www.nabble.com/turning-list-into-vector-dataframe-tp22984623p22984623.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@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.
_____________________________
Baptiste AuguiƩ
School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK
Phone: +44 1392 264187
http://newton.ex.ac.uk/research/emag
______________________________________________
R-help@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.