相关疑难解决方法(0)

plot.window(...)出错:需要有限的'xlim'值

我该怎么办这个错误?我的代码是:

library(e1071)
library(hydroGOF)
donnees <- read.csv("F:/new work with shahab/Code-SVR/SVR/MainData.csv")
summary(donnees)

#partitioning into training and testing set
donnees.train <- donnees[donnees$subset=="train",2:ncol(donnees)]
donnees.test <- donnees[donnees$subset=="test",2:ncol(donnees)]

#use the mean of the dependent variable as a predictor
def.pred <- mean(donnees.train$y)

#error sum of squares of the default model on the test set
def.rss <- sum((donnees.test$y-def.pred)^2)
print(def.rss)
plot(donnees.train)
#*****************
#linear regression
#*****************
#Linear Models
reg <- lm(y ~., data = donnees.train)
print(summary(reg))
#error sum of squares of the model on the test set
reg.pred <- predict(reg,newdata …
Run Code Online (Sandbox Code Playgroud)

r

19
推荐指数
2
解决办法
11万
查看次数

将基本 r 图保存为可以在多重图中绘制的对象

这个问题是从一篇相关文章构建的,该文章展示了如何使用包中的函数轻松地将绘图存储为r对象。伟大的!但是,我现在想创建一个将基本 r 图与 2 个数字相结合的多重图。我在用%<a-%pryrggplotgrid.arrange下面。

使用基本 rcars数据我可以制作两个ggplot数字。

library(ggplot2)
library(pryr)
library(gridExtra)

Fig1 <- qplot(speed, data=cars, geom="histogram")
Fig2 <- qplot(dist, speed, data=cars, geom="point")
Run Code Online (Sandbox Code Playgroud)

然后,我使用 制作一个图形,并使用包中的函数plot将该图形保存为对象。光滑。%<a-%pryr

Fig3 %<a-% plot(cars$speed, cars$dist)
Fig3
Run Code Online (Sandbox Code Playgroud)

最后,我想将这 3 个数字组合成一个图,如下所示。

Figs <- grid.arrange(Fig1, Fig2, Fig3,
                     layout_matrix = rbind(c(1,1,1,2,2), c(1,1,1,2,2), c(3,3,3,3,3)))
Run Code Online (Sandbox Code Playgroud)

该代码产生以下错误:

Error in gList(list(grobs = list(list(x = 0.5, y = 0.5, width = 1, height = 1,  : 
  only 'grobs' allowed in …
Run Code Online (Sandbox Code Playgroud)

plot r ggplot2 pryr

5
推荐指数
1
解决办法
4321
查看次数

将 corrplot 输出转换为 grob

我正在尝试使用 grid.arrange 组合多种类型的图形/表格,其中之一是使用corrplot. 有没有办法将 corrplot 转换为 grob 或导出/导入为与 兼容的图像grid.arrange?由于我组合的其他图来自 ggplot 和 tableGrob,我似乎无法使用par(mfrow = c(2, 2))layout(matrix(1:2))按照其他帖子中的建议。

P1 <- corrplot(PANAcor, order="hclust", addgrid.col = "gray",  
               type="full", col = col2(50), tl.cex=1.5, tl.col="black", 
               method="color", tl.pos="lt", tl.srt=45, hclust.method = "average",
               cl.ratio = 0.25, cl.align = "l", number.cex = 2)

summary <- grid.arrange(
    top=textGrob(sprintf("%s Summary",subject), gp=gpar(fontsize=16,font=8)),
    blank, P1, P2,
    blank, T1, T2,
    ncol=3, widths = c(0.1, 3, 3), 
    nrow=2, heights= c(1, 1),
    bottom = textGrob(sprintf("%s run %s",version,runtime), 
    gp=gpar(fontsize=6,font=8), hjust=-1) …
Run Code Online (Sandbox Code Playgroud)

r grob r-corrplot

2
推荐指数
1
解决办法
4133
查看次数

标签 统计

r ×3

ggplot2 ×1

grob ×1

plot ×1

pryr ×1

r-corrplot ×1