【发布时间】:2021-05-20 21:12:17
【问题描述】:
我无法解决这个问题。我想创建一个带有每个标点符号计数的图(; - . ,)。 我有这个代码
wekto<-c("Robot, robot; Nose, nose; Robot, robot; Toes, toes; Robot, robot - touch your nose. Robot, robot - touch your toes.")
stops <- function(text){
wekto%>%
str_remove_all("[A-z]") %>%
str_split(pattern = " ") %>%
table() %>%
as.data.frame %>%
setNames(c("Punctuation","Count"))%>%
ggplot(aes(x=Punctuation,y=Count)) +
geom_col() +
coord_flip()+
theme_classic()+
theme(axis.text.y = element_text(size = 17))
}
但我希望它显示没有空格,由于双空格,这些空格被添加到我的数据框中。
我怎样才能删除它们?
我用str_remove 和str_replace 试过了,但它不起作用
【问题讨论】: