Hello, users. Dear users,
*******I have a function f to simulate data from a model (example below used only to show my problems) f<-function(n,mean1){ a<-matrix(rnorm(n, mean1 , sd = 1),ncol=5) b<-matrix(runif(n),ncol=5) data<-rbind(a,b) out<-data out} *********I want to simulate 1000 datasets (here only 5) so I use S<-list() for (i in 1:5){ S[[i]]<-f(n=10,mean1=0)} ******I have a very complicated function for estimation of a model which I want to apply to Each one of the above simulated datasets fun<-function(data){data<-as.matrix(data) sink(' Example.txt',append=TRUE) cat("\n***********************\nEstimation \n********************\nDataset Sim : ", i ) d<-data%*%t(data) s<-solve(d) print(s) out<-list (s,d) out } results<-list() for(i in 1:5){ tmp <- try(fun(data=S[[i]])) results[[i]] <- ifelse(is(tmp,"try-error"),NA,tmp) } ####My problem is that results have only the 1st element of the result lists of fun (i.e. only ####although tmp gives me both s and d. Thanks Evgenia -- View this message in context: http://r.789695.n4.nabble.com/Function-try-and-Results-of-a-program-tp2526621p2526621.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.