Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R-在列表中存储plotly对象_R_Plotly - Fatal编程技术网

R-在列表中存储plotly对象

R-在列表中存储plotly对象,r,plotly,R,Plotly,我试图在for循环中生成不同的绘图,并将它们保存到列表中。问题是plotly的数据不是静态的,在每个循环中,所有的绘图都在变化。 这是我的密码: library(plotly) data("iris") names = names(iris)[-5] plotList <- list() for (i in 1:length(names)) { for (j in 1:length(names)) { name = paste("plot", i, j, sep = "_")

我试图在for循环中生成不同的绘图,并将它们保存到列表中。问题是plotly的数据不是静态的,在每个循环中,所有的绘图都在变化。 这是我的密码:

library(plotly)
data("iris")
names = names(iris)[-5]

plotList <- list()
for (i in 1:length(names)) {
  for (j in 1:length(names)) {
    name = paste("plot", i, j, sep = "_")
    p <- (plot_ly(data = iris, x = ~get(names[i]), y = ~get(names[j]),
                  type = "scatter", mode = "markers") %>%
            layout(
              title = paste(names[i], names[j], sep = " vs "),
              xaxis = list(title = names[i]),
              yaxis = list(title = names[j])))
    plotList[[name]] <- p
  }
}

plotList$plot_4_3
plotList$plot_4_4 
library(plotly)
数据(“iris”)
姓名=姓名(虹膜)[-5]

plotListAdd
plotly\u build

library(plotly)
data("iris")
names = names(iris)[-5]

plotList <- list()
for (i in 1:length(names)) {
    for (j in 1:length(names)) {
        name = paste("plot", i, j, sep = "_")
        plotList[[name]] <- plotly_build(plot_ly(data = iris, x = ~get(names[i]), y = ~get(names[j]),
                      type = "scatter", mode = "markers") %>%
                  layout(
                      title = paste(names[i], names[j], sep = " vs "),
                      xaxis = list(title = names[i]),
                      yaxis = list(title = names[j])))
    }
}

plotList$plot_4_3
plotList$plot_4_4 
library(plotly)
数据(“iris”)
姓名=姓名(虹膜)[-5]
绘图仪
library(plotly)
data("iris")
names = names(iris)[-5]

plotList <- list()
for (i in 1:length(names)) {
    for (j in 1:length(names)) {
        name = paste("plot", i, j, sep = "_")
        plotList[[name]] <- plotly_build(plot_ly(data = iris, x = ~get(names[i]), y = ~get(names[j]),
                      type = "scatter", mode = "markers") %>%
                  layout(
                      title = paste(names[i], names[j], sep = " vs "),
                      xaxis = list(title = names[i]),
                      yaxis = list(title = names[j])))
    }
}

plotList$plot_4_3
plotList$plot_4_4