I am trying to create my own function to avoid the duplication of data object and I created following code:
check_data_exist <- function(data){
if(exists("data")==TRUE){
z=y
} else
x = seq(1,10)
}
However, my function is not doing anything and also not giving me any error message. I would be grateful for the suggestions
CodePudding user response:
Just to let that I found the error that braces were missing. I corrected as follows (just in case someone is struggling like me)
check_data_exist <- function(data){
if(exists("data")==TRUE){
z=y
} else{
x = seq(1,10)
}
}
Anyway, many thanks.