小编Kat*_*808的帖子

使用R中的apply结构化循环内的计数器

我试图从R中相当复杂的数组进行绘制.我想生成一个包含3×3图形的图像,每个图形上都有红色和蓝色点.

我有一个应用循环的结构,但我想改变每行的y最大值.

我通常会使用像我这样的计数器在其他语言中这样做.但R中的应用事情让我感到困惑!

par(mfrow=c(3,3),pty="s")             # a 3 by 3 graphic
set.seed(1001)

x <- 1:54                             # with 1 to 54 along the x axis

y <- array(rexp(20), dim=c(54,6,3,2)) # and the y axis coming 
                                      # from an array with dimensions as shown.

ymax <- c(1,0.1,0.3)                  # three different y maximum values I want 
                                      # on the graphic, one for each row of graphs

counter <- 1                          # a counter, starting at 1, 
                                      # as I would use in a traditional loop …
Run Code Online (Sandbox Code Playgroud)

plot counter r apply

4
推荐指数
2
解决办法
5400
查看次数

标签 统计

apply ×1

counter ×1

plot ×1

r ×1