[R] skip on error

Jim Holtman jholtman at gmail.com
Tue Nov 8 11:57:11 CET 2011


?try

Sent from my iPad

On Nov 8, 2011, at 5:49, Alaios <alaios at yahoo.com> wrote:

> Dear all,
> I have a different data sets and I am doing some calculations over time,
> 
> For that every data set is split into junks based on the time stamps
> so one data set has like 10 timestamps.
> 
> There is also the case that one data set has less than 10 timestamps.
> 
> In my code I was doing the following
> 
> lapply(Datasource,analysis_for_one_data_source)
> 
> lapply(TimeFrames,analysis_for_one_data_source_and_one_time_frame)
> 
> as you can imagine there are times where the second lapply will "explode" 
> 
> 
> analysis_for_one_data_source_and_one_time_frame<- function( DataSource, TimeFrame,) {
>         return( do_analysis(DataSource,TimeFrame))
>         
> }
> 
> as you can understand this will return an error for a given Datasource that does not have a timestamp. I was looking though if I can ask from R to handle the error by continuing to the next one. So the lapply that returns and error can for example to store the error message to the list it returns and continue to the next element of the lapply list
> 
> Would that be possible in R?
> B.R
> Alex
> 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> 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