问题描述
我尝试使用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 (将#修改为@)