R 什么';it’这个语料库中的文本是小写的,我怎样才能把它变成大写呢?

R 什么';it’这个语料库中的文本是小写的,我怎样才能把它变成大写呢?,r,uppercase,corpus,word-cloud,R,Uppercase,Corpus,Word Cloud,我试图在R中构建一个单词云,但它只返回小写文本 sheet <- read_excel('list_products.xls', skip = 4) products <- c(sheet$Cod) products <- Corpus(VectorSource(products)) c_words <- brewer.pal(8, 'Set2') wordcloud(products, min.freq = 10, max.words = 30, scale = c(7

我试图在
R
中构建一个单词云,但它只返回小写文本

sheet <- read_excel('list_products.xls', skip = 4)
products <- c(sheet$Cod)
products <- Corpus(VectorSource(products))
c_words <- brewer.pal(8, 'Set2')
wordcloud(products, min.freq = 10, max.words = 30, scale = c(7,1), colors = c_words)

sheet正如您在这里看到的:,当您执行
TermDocumentMatrix(CORPUS)
时,默认情况下,单词是小写的。
事实上,如果您在没有参数
freq
的情况下进行
trace(wordcloud)
tdm感谢您做出如此清晰的指示。我很抱歉没有提供足够的内容来复制我的代码。
products <- tm_map(products, content_transformer(toupper))
filePath <- "http://www.sthda.com/sthda/RDoc/example-files/martin-luther-king-i-have-a-dream-speech.txt" # I am using this text because you DID NOT PROVIDED A REPRODUCIBLE EXAMPLE
text <- readLines(filePath)
products <- Corpus(VectorSource(text))
products <- tm_map(products, toupper)
c_words <- brewer.pal(8, 'Set2')
tdm <- tm::TermDocumentMatrix(products, control = list(tolower = F))
freq_corpus <- slam::row_sums(tdm)
wordcloud(names(freq_corpus), freq_corpus, min.freq = 10, max.words = 30, scale = c(7,1), colors = c_words)
filePath <- "http://www.sthda.com/sthda/RDoc/example-files/martin-luther-king-i-have-a-dream-speech.txt"
text <- readLines(filePath)
products <- Corpus(VectorSource(text))
products <- tm_map(products, toupper)
c_words <- brewer.pal(8, 'Set2')
wordcloud(names(freq_corpus), freq_corpus, min.freq = 10, max.words = 30, scale = c(7,1), colors = c_words)