How to save a variable as a data frame in R

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'm 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 Pat1 is a data table from which you take Pat1 $ Patient comment as a 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
+4
source share
2 answers

Give it a try Sent[[all]]. See if this helps.

+1
source

. qdap - , ... ?

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

derive_pubkey ():
RAW() 'raw', 'list'

. - ? derive_pubkey(key) - ?

0

Source: https://habr.com/ru/post/1661972/


All Articles