I am trying to add rows to a data frame if it exists, or assign it to initial data frame in case it doesn't exists. I have tried exists()
, missing()
, etc, but nothing is working for me.
exists(data) && is.data.frame(get(data))
Error in exists(data) : object 'data' not found
Any help would be highly appreciated. I am trying to do something like
if(exists(data))
data <- rbind(data,new_data)
else
data <- new_data
答案 0 :(得分:1)
If you read the documentation you’ll see that it says that exists
requires
a variable name (given as a character string).
In other words, write:
exists('data') && is.data.frame(get('data'))