首页 > 解决方案 > abs(x) 中的错误:数学函数 R lang 的非数字参数

问题描述

R中的新手,有一个问题,但不明白它到底有什么问题。单独的代码工作正常。我一起收到这个错误

 Error in abs(x) : non-numeric argument to mathematical function
In addition: Warning message:
Removed 1 row(s) containing missing values (geom_path). 

代码在这里

p + ggtitle("BTC Price Prformance") + 
  theme(plot.title = element_text(color="#002D7D", size=14, face="bold", hjust = 0.5)) + 
  theme(plot.title = element_text(color="#002D7D", size=14, face="bold", hjust = 0.5)) + 
  scale_x_continuous(limits = c(1,nrow(mResult)), expand = c(0, 0), breaks = as.numeric(mXLabels[,1]), labels = mXLabels[,2])  + 
  scale_y_continuous(limits = c(0,max( excelSheet$High[excelSheet$High!=max(excelSheet$High)] )), expand = c(0, 0), breaks=c(0, 2500, 5000, 7500, 10000, 12500, 15000, 17500, 20000)) + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

标签: r

解决方案


错误消息说您缺少值。尝试

your_variable <- na.omit(your_variable)

得到一个无 na 的向量。


推荐阅读