Project

General

Profile

« Previous | Next » 

Revision 515ef436

Added by Benoit Parmentier over 8 years ago

remove error from list following new bug in the code for reg5 Africa accuracy layer

View differences:

climate/research/oregon/interpolation/global_run_scalingup_mosaicing_function.R
4 4
#Different options to explore mosaicing are tested. This script only contains functions.
5 5
#AUTHOR: Benoit Parmentier 
6 6
#CREATED ON: 04/14/2015  
7
#MODIFIED ON: 06/19/2016            
7
#MODIFIED ON: 06/23/2016            
8 8
#Version: 2
9 9
#PROJECT: Environmental Layers project     
10 10
#COMMENTS: first commit of function script to test mosaicing using 1500x4500km and other tiles
......
1818 1818

  
1819 1819
}
1820 1820

  
1821
remove_errors_list<-function(list_items){
1822
  
1823
  #This function removes "error" items in a list
1824
  list_tmp<-list_items
1825
    if(is.null(names(list_tmp))){
1826
    names(list_tmp) <- paste("l",1:length(list_tmp),sep="_")
1827
    names(list_items) <- paste("l",1:length(list_tmp),sep="_")
1828
  }
1829

  
1830
  for(i in 1:length(list_items)){
1831
    if(inherits(list_items[[i]],"try-error")){
1832
      list_tmp[[i]]<-0
1833
    }else{
1834
    list_tmp[[i]]<-1
1835
   }
1836
  }
1837
  cnames<-names(list_tmp[list_tmp>0])
1838
  x <- list_items[match(cnames,names(list_items))]
1839
  return(x)
1840
}
1841

  
1821 1842
##################### END OF SCRIPT ######################

Also available in: Unified diff