1 Reply Latest reply on Oct 16, 2016 3:04 PM by Yuriy Fal

    Error in SCRIPT_SCR with R Integration

    Sandeep Kotha

      Hi All,

       

      I am trying to run the Text analytics R commands in Tableau as shown below.

       

      SCRIPT_STR(

      "library(qdap);

      mycorpus<-Corpus(VectorSource(.arg1))

      inspect(mycorpus[1:4])

      mycorpus<-tm_map(mycorpus,tolower)

      mycorpus<-tm_map(mycorpus,removePunctuation)

      mycorpus<-tm_map(mycorpus,removeNumbers)

      mycorpus<-tm_map(mycorpus,stripWhitespace)

      mycorpus<-tm_map(mycorpus,PlainTextDocument)

      mydf<-data.frame(text=unlist(sapply(mycorpus,'[',"content")),stringAsFactors=FALSE)

      mydf$text<-as.character(mydf$text)

      a <- unlist(apply(mydf,1,function(x) polarity(x[1])[[2]]$ave.polarity))

      attributes(a) <- NULL

      a  <- as.vector(a)

      score <- data.frame("Sentence_Num" = 1:nrow(mydf),"Sentiment Score" = a)

      " ,ATTR([Text])

      )

      In the above commands, i am getting the error in the line "mydf<-data.frame(text=unlist(sapply(mycorpus,'[',"content")),stringAsFactors=FALSE)" at "Content" .Below is the snapshot.

       

      Can someone help me with correction of my code?

       

      Best Wishes,

      Sandeep