In Dave´s answer to 'Creating edges (rows) for several mentions in one tweet' running the folliwing Script:
plyr::ddply(tweets, c("text"), function(x){
mention <- unlist(stringr::str_extract_all(x$text, "@\\w+"))
# some tweets do not contain mentions, making this necessary:
if (length(mention) > 0){
return(data.frame(mention = mention))
} else {
return(data.frame(mention = NA))
}})
I have a problem for some tweets list. I got the error:
Error in if (empty(.data)) return(.data) :
missing value where TRUE/FALSE needed.
Thanks for help.
Compare these two results:
if(NA > NA) 'yes' else 'no'
#Error in if (NA > NA) "yes" else "no" :
# missing value where TRUE/FALSE needed
if(NA > NA && !is.na(NA > NA)) 'yes' else 'no'
#[1] "no"
The first expression is returning the same error message that you received for similar reasons. The conditional test is expecting a TRUE
or FALSE
in order to move on. My test NA > NA
does not have a truth value so NA
is returned. Therefore in the second test I included an extra check to ignore NA
conditional results.