Просмотр исходного кода

Add: real Date-Time-Timezone string

pull/8/head
janwey 1 год назад
Родитель
Сommit
f6c36b1d07
1 измененных файлов: 12 добавлений и 6 удалений
  1. 12
    6
      collecto.R

+ 12
- 6
collecto.R Просмотреть файл

@@ -143,6 +143,7 @@ time <- sub(pattern = ".* ", x = twitter_timedate, replace = "")
time <- gsub(pattern = ":", x = time, replace = "")
date <- sub(pattern = " .*", x = twitter_timedate, replace = "")
date <- gsub(pattern = "-", x = date, replace = "")
fdat <- strptime(x = paste0(date, time), format = "%Y%m%d%H%M%S", tz = "CET")
retw <- as.factor(twitter_rts)
favs <- as.factor(twitter_fav)
link <- as.character(twitter_url)
@@ -151,14 +152,15 @@ clnt <- as.character(twitter_client)
user <- as.character(twitter_usr)

### Creating dataframe
twitter <- data.frame(cbind(date, time, retw, favs, text, link, clnt, user))
twitter <- data.frame(cbind(date, time, fdat, retw, favs, text, link, clnt, user))

#### Clean-Up
rm(list = c("date", "time", "retw", "favs", "text", "link", "clnt", "user"))
rm(list = c("date", "time", "fdat", "retw", "favs", "text", "link", "clnt", "user"))

twitter <- within(data = twitter, expr = {
date <- as.character(date);
time <- as.character(time);
fdat <- as.character(fdat);
text <- as.character(text);
link <- as.character(link);
})
@@ -306,13 +308,15 @@ for(i in 1:999){
}

### Time of post
#### date (as numeric value)
#### date
date <- sub(pattern = "T.*", x = datetime, replacement = "")
date <- gsub(pattern = "-", x = date, replacement = "")
#### time (as numeric value)
#### time
time <- sub(pattern = ".*T", x = datetime, replacement = "")
time <- sub(pattern = "\\..*", x = time, replacement = "")
time <- gsub(pattern = ":", x = time, replacement = "")
#### full time
fdat <- strptime(x = paste0(date, time), format = "%Y%m%d%H%M%S", tz = "CET")

### Removing HTML-Tags from Toots
text <- gsub(pattern = "<.*?>", x = text, replacement = "")
@@ -330,6 +334,7 @@ inst <- sub(pattern = "\\/.*", x = inst, replacement = "")
mastodon_exclude <- which(as.numeric(date) < 20180210)
date <- date[-mastodon_exclude]
time <- time[-mastodon_exclude]
fdat <- fdat[-mastodon_exclude]
lang <- lang[-mastodon_exclude]
inst <- inst[-mastodon_exclude]
text <- text[-mastodon_exclude]
@@ -340,14 +345,15 @@ murl <- murl[-mastodon_exclude]
acct <- acct[-mastodon_exclude]

### Creating dataframe
mastodon <- data.frame(cbind(date, time, lang, inst, text, link, reto, favs, murl, acct))
mastodon <- data.frame(cbind(date, time, fdat, lang, inst, text, link, reto, favs, murl, acct))

#### Clean-Up
rm(list = c("date", "time", "lang", "inst", "text", "link", "favs", "reto", "murl", "datetime", "acct"))
rm(list = c("date", "time", "fdat", "lang", "inst", "text", "link", "favs", "reto", "murl", "datetime", "acct"))

mastodon <- within(data = mastodon, expr = {
date <- as.character(date);
time <- as.character(time);
fdat <- as.character(fdat);
text <- as.character(text);
link <- as.character(link);
murl <- as.character(murl);

Загрузка…
Отмена
Сохранить