Browse Source

Edit: small fixes of the Reddit-Section

pull/3/head
janwey 1 year ago
parent
commit
9bc7332c1e
1 changed files with 8 additions and 7 deletions
  1. 8
    7
      collecto.R

+ 8
- 7
collecto.R View File

@@ -14,7 +14,7 @@ library("twitteR")
#### Fediverse (eg: mastodon)
install.packages("devtools")
# requires libssl-dev
devtools::install_github("ThomasChln/mastodon")
devtools::install_github("ThomasChln/mastodon", force = TRUE)
library("mastodon")

### Reddit
@@ -183,7 +183,7 @@ mastodon_auth <- mastodon::login(instance = mastodon_auth_insta,
mastodon_toot <- mastodon::get_hashtag(token = mastodon_auth,
hashtag = "ilovefs",
local = FALSE,
n = 100)
n = 20)

### public and non-public posts
mastodon_priv <- mastodon_toot[[7]]
@@ -283,7 +283,7 @@ reddit_searchinyear <- 18 # has to have format "YY", eg "18" for "2018"
reddit_post_year <- gsub(x = reddit_post_dirty$date,
pattern = "\\d.-\\d.-",
replace = "")
reddit_post <- reddit_post_dirty[which(reddit_post_year == reddit_searchfromyear),]
reddit_post <- reddit_post_dirty[which(reddit_post_year == reddit_searchinyear),]

### Extracting relevant variables
comt <- c() # Comments / Replies
@@ -301,10 +301,11 @@ for(i in c(1:length(reddit_post$URL))){
date[i] <- gsub(x = reddit_post$date[i], pattern = "-", replace = "")
subr[i] <- reddit_post$subreddit[i]

reddit_content <- reddit_content(URL = reddit_post$URL[i])
ptns[i] <- reddit_content$post_score
text[i] <- reddit_content$post_text
link[i] <- reddit_content$link
Sys.sleep(2)
reddit_content <- reddit_content(URL = reddit_post$URL[i], wait_time = 0)
ptns[i] <- reddit_content$post_score[1]
text[i] <- reddit_content$post_text[1]
link[i] <- reddit_content$link[1]
}

### Creating dataframe

Loading…
Cancel
Save