Control structures

Trycatch

tryCatch({
		myVar = myCodeBlock()
	}, 
	# If codeblock fails print message and return NA
	error = function(cond){
		message(cond)
		return (list('myVar' = NA))
	})
	# Else return value
	return (list('myVar' = myVar, 
	

Swithc


testVar = 'value_1'
dependentVal=''

switch(testVar,
			value_1 = {dependentVal = 'Val_x'},
			value_2 = {dependentVal = 'Val_y'},
			dependentVal = 'default'
			 )

# prints "Val_x"
print(dependentVal)