我使用以下代码拟合模型
mod1 <- gam(severity ~ s(mean_rh, k = 8) + s(mean_temp, k = 10) + s(mean_ws, k =7) + s(avg_daily_rain, k = 7), family = betar(), data = dat_seasonal)
下面是用于生成绘图的代码
plot(mod1, pages = 1, all.terms = TRUE, rug = TRUE, residuals = TRUE, pch = 1, cex = 1, shade = TRUE, seWithMean = TRUE, shift = coef(mod1)[1])
我想通过重命名原始数据框中的列名来重命名x轴标注,使用新名称=旧语法Mean temperature
= mean_temp,Mean wind speed
= mean_ws,Mean relative humidity
= mean_rh,Mean rain per rainy day
= avg_daily_rain
下面是我的代码
names(dat_seasonal) <- c("disease_severity", "Mean relative humidity", "Mean temperature", "Mean wind speed", "Mean rain per rainy day")
mod1 <- gam(disease_severity ~ s(`Mean relative humidity`, k = 8) + s(`Mean temperature`, k = 10) + s(`Mean wind speed`, k =7) + s(`Mean rain per rainy day`, k = 7), family = betar(), data = dat_seasonal_gam)
summary(mod1)
plot(mod1, pages = 1, all.terms = TRUE, rug = TRUE, residuals = TRUE, pch = 1, cex = 1, shade = TRUE, seWithMean = TRUE, shift = coef(mod1)[1])
我收到以下错误消息
Error in str2lang(termtext) : <text>:1:6: unexpected symbol
1: Mean relative
^
显然,错误消息建议在新名称中不应该有任何空格。有没有解决这个问题的线索?谢谢
注意:我可以使用下面的代码重命名单个项,但无法一次重命名所有预测器。
plot(mod1, select = 4, xlab = "Mean rain per rainy day (mm)", rug = TRUE, residuals = TRUE, pch = 1, cex = 1, shade = TRUE, seWithMean = TRUE, shift = coef(mod1)[1])
1条答案
按热度按时间umuewwlo1#
最后使用
gratia
包重命名各个图,然后使用patchwork
包将它们组合在一起。