代码如下,
ggplot(book_words,aes(x=keywords,y=numbers))+
geom_bar(show.legend = FALSE,stat="identity",na.rm = TRUE)
其中book_words的类型为DataFrame,如下图
其包括两列,分别是keywords和numbers,数据类型同上。
但是我在运行代码之后报错提示:
Error in `geom_bar()`:
! Problem while setting up geom.
ℹ Error occurred in the 1st layer.
Caused by error in `abs()`:
! non-numeric argument to mathematical function
Run `rlang::last_trace()` to see where the error occurred.
我通过class(book_words$numbers)等测试出来numbers字段明明为数值型,为什么会一直报错提示non-numeric argument呢?
你最好把文件发给我测试一下,要不然说不明白