4

I am new to R and programming in general and am trying to create a program that will collect and analyze data from twitter. The code I am using is below:

install.packages(c("devtools", "rjson", "bit64", "httr"))

library(devtools)

library(twitteR)

APIkey <- "xxxxxxxxxxxxxxxxxxxxxx"
APIsecret <- "xxxxxxxxxxxxxxxxxxxxxxxxx"
accesstoken <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
accesstokensecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

setup_twitter_oauth(APIkey,APIsecret,accesstoken,accesstokensecret)


Pat1$Patientsentiment <- tolower (Pat1$Patientcomment)

library(qdap)

Sent<-polarity(Pat1$Patientcomment, grouping.var = Pat1$Pat.NUMBER,

           positive.list = positive.words,

           negative.list = negative.words,

           negation.list = negation.words,

           amplification.list = increase.amplification.words,

           rm.incomplete = FALSE, digits = 3)

RPatient_Polarity <- data.frame(Sent$all)

I am trying to figure out how to save Pat1 as a data frame so that Pat1 is a data table from which you take Pat1$Patientcomment as variable.

When I run the program now, I get the following result:

> library(devtools)
> library(twitteR)
> APIkey <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> APIsecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> accesstoken <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> accesstokensecret <- "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
> setup_twitter_oauth(APIkey,APIsecret,accesstoken,accesstokensecret)
[1] "Using direct authentication"
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called       
setup_twitter_oauth()'
> Pat1$Patientsentiment <- tolower (Pat1$Patientcomment)
> library(qdap)
> Sent<-polarity(Pat1$Patientcomment, grouping.var = Pat1$Pat.NUMBER,
+                
+                positive.list = positive.words,
+                
+                negative.list = negative.words,
+                
+                negation.list = negation.words,
+                
+                amplification.list = increase.amplification.words,
+                
+                rm.incomplete = FALSE, digits = 3)
Error in derive_pubkey(key) : 
  RAW() can only be applied to a 'raw', not a 'list'
> RPatient_Polarity <- data.frame(Sent$all)
Error in data.frame(Sent$all) : object 'Sent' not found

2 Answers 2

1

Try Sent[[all]]. See if it helps.

Sign up to request clarification or add additional context in comments.

Comments

0

I am working on a sentiment analysis. For polarities, I used the qdap package and having the same error for all reviews - for single sentences as well as for single words... why this happening?

library(qdap)    
polarity("I love to eat")

Error in derive_pubkey(key) :
RAW() can only be applied to a 'raw', not a 'list'

I consulted this article. Is there something I missed? derive_pubkey(key) - what does this mean?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.