Plumber package does not read correctly functions of dplyr package

I want to use r codes, which clean data and then produce wordcloud, as Plumber API in order to use React.js
When i use Plumber package and its code to get API, dplyr package's codes do not work. Codes is:

library(dplyr)

text2<-select(text, "Başvuru Tipi", "Başvuru Açıklaması")
names(text2)[names(text2) == "Başvuru Tipi"] <- "Label"
names(text2)[names(text2) == "Başvuru Açıklaması"] <- "Text"

How can i fix this problem?
Thanks a lot your effort

**error**
message: Unknown column `BaÅŸvuru Tipi` 
class:   `rlang_error`
backtrace:
  1. plumb(file = "C:/Users/VPN/Desktop/tm/papi/plumber.R")$run()
 36. dplyr:::select.data.frame(text, "Başvuru Tipi", "Başvuru Açıklaması")
 37. tidyselect::vars_select(tbl_vars(.data), !!!enquos(...))
 38. tidyselect:::vars_select_eval(.vars, quos)
 39. purrr::map_if(ind_list, is_character, match_strings, names = TRUE)
 40. purrr::map(.x[sel], .f, ...)
 41. tidyselect:::.f(.x[[i]], ...)
 42. tidyselect:::bad_unknown_vars(vars, unknown)
Call `rlang::last_trace()` to see the full backtrace

All of the codes:

#
# This is a Plumber API. You can run the API by clicking
# the 'Run API' button above.
#
# Find out more about building APIs with Plumber here:
#
#    https://www.rplumber.io/
#

library(plumber)
library(readxl)
library(dplyr)
library(quanteda)
library(SnowballC)
library(stopwords)
library(wordcloud)
library(RColorBrewer)

#* @apiTitle Wordcloud API


#* Create wordcloud
#* @png
#* @get /plot
function() {
  
  
  text <- read_excel("C:/Users/VPN/Desktop/tm/text.xlsx")
  stopwordsPL <- readLines("stopwords.csv")
  stopwordsPL1 <- readLines("stopwords1.csv")
  
  
  colnames(text) = text[1, ]
  text = text[-1, ] 
  
  
  
  text2<-select(text, "Ba<U+663C><U+3E65>vuru Tipi", "Ba<U+663C><U+3E65>vuru A<U+653C><U+3E37><U+663C><U+3E64>klamas<U+663C><U+3E64>")
  names(text2)[names(text2) == "Ba<U+663C><U+3E65>vuru Tipi"] <- "Label"
  names(text2)[names(text2) == "Ba<U+663C><U+3E65>vuru A<U+653C><U+3E37><U+663C><U+3E64>klamas<U+663C><U+3E64>"] <- "Text"
  
  
  
  
  
  
  train.tokens<-tokens(text2$Text, what="word",
                       remove_numbers=TRUE, remove_symbol=TRUE, remove_separators=TRUE,
                       remove_punct= TRUE, remove_hyphens=TRUE)
  
  train.tokens<-tokens_tolower(train.tokens)
  
  train.tokens1<-tokens_select(train.tokens, stopwords("tr", source = "stopwords-iso"),
                               selection = "remove")
  
  train.tokens1<-tokens_remove(train.tokens1, pattern = phrase(stopwordsPL), valuetype = 'fixed')
  
  
  #train.tokens1<-tokens_wordstem(train.tokens1, language = "turkish")
  
  train.tokens1 <- tokens_remove(train.tokens1, stopwordsPL, padding = TRUE)
  
  
  ## N grams
  
  toks_ngram <- tokens_ngrams(train.tokens1, n = 2)
  
  toks_ngram<-tokens_remove(toks_ngram, pattern = phrase(stopwordsPL1), valuetype = 'fixed')
  
  
  train.tokens.dfm<-dfm(toks_ngram)
  train.tokens.matrix<-as.matrix(train.tokens.dfm)
  
  
  
  ## wordcloud 2
  
  
  words <- sort(colSums(train.tokens.matrix),decreasing=TRUE) 
  df <- data.frame(word = names(words),freq=words)
  
  
  wordcloud(words = df$word, freq = df$freq, min.freq = 8,
            random.order=FALSE,
            colors=brewer.pal(8, "Dark2"))
  
  
}

Created on 2019-12-16 by the reprex package (v0.3.0)

While most things will work on windows, Windows has a hard time with UTF8 encoding.

I believe you'll have to use Docker on your windows machine. Please see https://www.rplumber.io/docs/hosting.html#docker for more information.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.