如何解决R levelplotux + c-1,1:二进制运算符的非数字参数
我尝试使用levelplot可视化热图,但出现此错误,请帮忙
这是.txt文件中的输入文件
df <- read.table("df.txt",header=TRUE)
head(df)
# x y value site
#1 m450b Amer2 -1.783879 2
#2 m542 Amer2 -1.783879 1
#3 m351 Amer2 -1.783879 2
class(df) #[1] "data.frame"
class(df$x) #[1] "character"
class(df$value) #[1] "numeric"
class(df$site) #[1] "integer"
df$y <- as.factor(df$y)
class(df$y) #[1] "factor"
#---------------------------------------
library(raster)
library(lattice)
levelplot(value ~ x + y,data = df,xlab = "x",ylab = "y",main = "plot") +
xyplot(y ~ x,panel = function(y,x,...) {
ltext(x = x,y = y,labels = df$site,cex = 1,font = 2,fontfamily = "HersheySans")
})
But got this ERROR:
Error in ux + c(-1,1) : non-numeric argument to binary operator
我试图从.txt文件中进行可视化显示
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。