script "03_cluster_tweets.R" fails to run
Closed this issue · 4 comments
When running line 272 of the _master.R
script, I get the following error message:
Twitter-for-Urban-Planning/datawork/_master.R
Line 272 in f8223b4
> # Cluster tweets into uniqe crashes
> source(file.path(code_tweets_all_dir, "code", "03_cluster_tweets.R"))
Error in `$<-.data.frame`(`*tmp*`, "id", value = 1:0) :
replacement has 2 rows, data has 0
After inspecting and mannually re-running the script datawork/tweets_all/code/03_cluster_tweets.R
, I saw the error occured when trying to generate the object tweets_all_clustered
in lines 13-20:
> tweets_all_clustered <- cluster_crashes_one_dataset(crashes_df = tweets_all,
+ time_var = "created_at_nairobitime",
+ lat_var = "lat_alg",
+ lon_var = "lon_alg",
+ vars_to_keep = c("tweet"),
+ time_thresh_hrs=4,
+ cluster_km=0.5,
+ cluster_id_only=F)
Error in `$<-.data.frame`(`*tmp*`, "id", value = 1:0) :
replacement has 2 rows, data has 0
The function cluster_crashes_one_dataset()
sits in the script functions_and_packages/clustering/cluster_crashes_into_unique_crashes.R
. I couldn't locate, though, which line of it is the one generating the error because it's a long function (100+ lines)
I just got the same error. It seems to be coming from line 7 of 03_cluster_tweets.R
: looks like there are no obs with [tweets_all$crash_tweet_algorithm == TRUE
In fact, the variable crash_tweet_algorithm
is not present in tweet_all
fixed! (I think!) @luizaandrade @luisesanmartin
indeed, it works now!