Skip to content

Commit

Permalink
Update User Level Calculation
Browse files Browse the repository at this point in the history
Change user level calculation to only include unique accounts.
  • Loading branch information
kurtawirth committed Nov 6, 2018
1 parent 9560af0 commit a12c180
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: botscan
Type: Package
Title: Scans Twitter Conversations For Bots
Version: 1.0.7
Version: 2.0.0
Author: Kurt Wirth and Ryan T. Moore
Maintainer: Kurt Wirth <KurtAWirth@gmail.com>
Description: This package accepts any Twitter search query as an input and
Expand Down
11 changes: 7 additions & 4 deletions R/botscan.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ botscan <- function(x, timeout = 30, n_tweets = 1000, retweets = FALSE, threshol

assign("df", df_userbots, envir=globalenv())

# Check scores against given threshold

nbots <- sum(df_userbots$cap.universal > threshold)

# Filter out accounts that fall below the given threshold

bots <- dplyr::filter(df_userbots, (df_userbots$cap.universal > threshold))
Expand All @@ -113,6 +109,13 @@ botscan <- function(x, timeout = 30, n_tweets = 1000, retweets = FALSE, threshol

if(user_level) {

# Check scores against given threshold

nbots <- sum(
(tweets$screen_name %in% bots$user.screen_name) &
(df_userbots$cap.universal > threshold)
)

n <- length(unique(tweets$screen_name))

return(nbots / n)
Expand Down

0 comments on commit a12c180

Please sign in to comment.