I've installed an R package, to create retweet cascades from a tweet object json file (here is the github page). Their code works with their sample data. Here is the 2 lines of code to create the cascades:
filepath <- system.file('extdata', 'tweets_anonymized.jsonl', package = 'evently')
cascades <- parse_raw_tweets_to_cascades(filepath, progress = F)
Note-1: the parse_raw_tweets_to_cascades
function (in tweet.R
file) create cascades from a given tweet object jsonl file.
PROBLEM: When I run it with my data (which seems to have the same structure), it correctly extract info (e.g., tweet_id, retweet_id, user_id, etc.) from data, but it doesn't create the cascades and shows this error:
Error in rep(1:nrow(index), cascade_sizes) : invalid 'times' argument
Apparently this error happens when the second argument (cascade_sizes
) is either negative or Null or a vector of variables. I tried to print the cascade_size using
print(paste("Mona Cascade sizes is", cascade_sizes))
which returns the following:
"Mona Cascade size is"
Note-2: After a specific line in this file (processed_tweets <- data.table::as.data.table(data.table::rbindlist(processed_tweets_batch))
), I see the following issues:
- no visible global function definition for functions: fwrite, :=, and setorder
- no visible binding for global variables for variables: tweet_time, absolute_time, start_ind, and end_ind
I've read may similar posts, including the followings, but I couldn't fix my error yet:
- how to use utils::globalVariables
- ggplot2 inside R packages: Notes during CRAN tests
- How can I handle R CMD check "no visible binding for global variable" notes when my ggplot2 syntax is sensible?
UPDATE-1:
For example, I added the following in the tweet.R file (which was suggested in several answers):
#' @import utils
utils::globalVariables(c("absolute_time", "start_ind", "end_ind"))
but I still get the same error.
UPDATE-2:
I also set those variables to NULL (as suggested here, but still I get the same error. I added the following line to the top of my function:
tweet_time <- end_ind <- start_ind <- absolute_time <- NULL