[R] turning list into vector/dataframe
Melissa2k9
m.mcquillan at lancaster.ac.uk
Fri Apr 10 10:03:57 CEST 2009
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.
More information about the R-help
mailing list