Error processing tweet JSON in R function: missing value where TRUE/FALSE needed

I am using a function which takes a raw tweet JSON file as input and outputs the retweet cascades. Here is a part of the function: if (api_version == 2) { parse_tweet <- function(tweet, keep_text = F) { tryCatch({ json_tweet <- jsonlite::fromJSON(tweet) id <- json_tweet$data$id magnitude <-zero_if_null(json_tweet$includes$users$public_metrics$followers_count) user_id <- json_tweet$data$author_id retweet_id <- NA if (keep_text) … Read more