Search
 
SCRIPT & CODE EXAMPLE
 

R

next element in a loop if error in r

# This solution still prints the error but doesn't stop the loop
for (i in 1:10) {
  tryCatch({
    print(i)
    if (i==7) stop("Urgh, the iphone is in the blender !")
  }, error=function(e){cat("ERROR :",conditionMessage(e), "
")})
}

[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6
[1] 7
ERROR : Urgh, the iphone is in the blender ! 
[1] 8
[1] 9
[1] 10
Comment

PREVIOUS NEXT
Code Example
R :: R gap between date add missing value 
R :: change the font of the title in a plot in r 
R :: meaning of %% R 
R :: barplot_density 
R :: how to pull all 500 stocks r 
R :: conditional mean statement r 
Rust :: rust lang sleep 
Rust :: rust print array 
Rust :: rust sort vector of number descending 
Rust :: rust get items in a list with index and value 
Rust :: rust sort 
Rust :: string to bytes rust 
Rust :: rust struct default values 
Rust :: rust array unique 
Rust :: armanriazi•rust•vec 
Rust :: rust read splited string as vector 
Rust :: rust lang underscore 
Rust :: stringify! in rust 
Rust :: armanriazi•rust•oop 
Rust :: armanriazi•rust•comparison•iter•vs•for 
Rust :: how to get text from a file and store it in a variable rust 
Rust :: armanriazi•rust•unsafe•safeabstraction 
Rust :: rust random float between 0 and 1 
Lua :: how to get a random number in lua 
Lua :: roblox make debounce 
Lua :: luau how to find something in table 
Lua :: lua create file 
Lua :: What is transparency in roblox 
Lua :: lua table to json 
Lua :: lua string 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =