由于我无法更改MainActivity,因此我想以编程方式添加接口。
我想要制作与...完全相同的代码
library(rtweet)
library(tidytext)
library(tidyverse)
library(BBmisc)
library(reshape)
create_token(
app = "Flippable Sentiment Analysis",
consumer_key = c_k,
consumer_secret = c_s,
access_token <- a_t,
access_secret <- a_s)
create_sentiment_df <- function(twitter.name, party, election.result) {
va_stop_words <- stop_words %>% select(-lexicon) %>%
bind_rows(data.frame(word = c("https", "t.co", "rt", "amp")))
nrc_lex <- get_sentiments("nrc") # many sentiments
dat <- get_timeline(twitter.name, n=3200)
dat$created_at <- as.Date(dat$created_at)
dat_2017 <- subset(dat, created_at > as.Date('2017-01-01') & created_at < as.Date('2017-11-06'))
dat_words <- dat_2017 %>%
select(status_id, text) %>%
unnest_tokens(word,text)
dat_words_interesting <- dat_words %>% anti_join(va_stop_words)
dat_sentiment <- dat_words_interesting %>% left_join(nrc_lex)
dat_sentiment_count <- dat_sentiment %>%
filter(!is.na(sentiment)) %>%
group_by(sentiment) %>%
summarise(prop.sentiment=n())
dat_sentiment_count <- na.omit(dat_sentiment_count)
dat_sentiment_count <- cbind(dat_sentiment_count[1],
prop.table(data.matrix(dat_sentiment_count[-1]), margin=2))
# dat_sentiment_count$twitter.name <- NA
dat_sentiment_count$twitter.name <- twitter.name
dat_sentiment_count$party <- party
dat_sentiment_count$election.result <- election.result
return(as.data.frame(dat_sentiment_count))
}
我以编程方式添加界面的概念:
class Activity implements Runnable{
}
有什么解决办法吗?