3

我在列表中保存了大约 30 个ggplot对象ggobject,现在我想要:

  • ggobject使用并行R 包绘制对象。
  • 另外,我想以网格方式显示这些图,为此我使用了multiplot函数。

我为此使用以下代码

no_cores <- detectCores()-1
cl2<- makeCluster(no_cores)
parLapply(cl2,ggobject,multiplot)
stopCluster(cl2)

我面临的主要问题是我应该如何表达网格排列(特定显示的列/行数)parLapply

在这里,我将一个对象粘贴在 ggobject

list(structure(list(data = structure(list(steps = c(63.8199996559892, 
64.8826470030449, 65.9452943501006, 67.0079416971563, 68.070589044212, 
69.1332363912677, 70.1958837383234, 71.2585310853791, 72.3211784324348, 
73.3838257794905, 74.4464731265462, 75.5091204736019, 76.5717678206576, 
77.6344151677133, 78.697062514769, 79.7597098618247, 80.8223572088804, 
81.8850045559361, 82.9476519029918, 84.0102992500475, 85.0729465971032, 
86.1355939441589, 87.1982412912146, 88.2608886382703, 89.323535985326, 
90.3861833323817, 91.4488306794374, 92.5114780264931, 93.5741253735488, 
94.6367727206045, 95.6994200676602, 96.7620674147159, 97.8247147617716, 
98.8873621088273, 99.950009455883, 101.012656802939, 102.075304149994, 
103.13795149705, 104.200598844106, 105.263246191161, 106.325893538217, 
107.388540885273, 108.451188232329, 109.513835579384, 110.57648292644, 
111.639130273496, 112.701777620551, 113.764424967607, 114.827072314663, 
115.889719661719, 116.952367008774, 118.01501435583, 119.077661702886, 
120.140309049941, 121.202956396997, 122.265603744053, 123.328251091108, 
124.390898438164, 125.45354578522, 126.516193132276, 127.578840479331, 
128.641487826387, 129.704135173443, 130.766782520498, 131.829429867554, 
132.89207721461, 133.954724561665, 135.017371908721, 136.080019255777, 
137.142666602833, 138.205313949888, 139.267961296944, 140.330608644, 
141.393255991055, 142.455903338111, 143.518550685167, 144.581198032222, 
145.643845379278, 146.706492726334, 147.76914007339, 148.831787420445, 
149.894434767501, 150.957082114557, 152.019729461612, 153.082376808668, 
154.145024155724, 155.207671502779, 156.270318849835, 157.332966196891, 
158.395613543947, 159.458260891002, 160.520908238058, 161.583555585114, 
162.646202932169, 163.708850279225, 164.771497626281, 165.834144973336, 
166.896792320392, 167.959439667448, 169.022087014504), count = c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 6L, 7L, 7L, 
9L, 10L, 10L), meanval = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1.07692307692308, 1.07692307692308, 1.07692307692308, 
1.07692307692308, 1.07692307692308, 1.07692307692308, 1.07407407407407, 
1.07407407407407, 1.07407407407407, 1.14814814814815, 1.2962962962963, 
1.2962962962963, 1.37037037037037, 1.51851851851852, 1.51851851851852, 
1.57142857142857, 1.57142857142857, 1.57142857142857, 1.55172413793103, 
1.62068965517241, 1.68965517241379, 2, 2, 2.26666666666667, 2.33333333333333, 
2.53333333333333, 2.53333333333333, 2.6, 3, 3.26666666666667, 
3.33333333333333, 3.73333333333333, 4.26666666666667, 4.46666666666667, 
4.86666666666667, 5.06666666666667, 5.66666666666667, 6, 6.2), 
    ymin = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 0.805176588728374, 0.805176588728374, 
    0.805176588728374, 0.805176588728374, 0.805176588728374, 
    0.805176588728374, 0.807193817732262, 0.807193817732262, 
    0.807193817732262, 0.692102966200999, 0.4728506829965, 0.4728506829965, 
    0.364688506461107, 0.362584984018227, 0.362584984018227, 
    0.311546994731147, 0.311546994731147, 0.311546994731147, 
    0.310002783849425, 0.355389207976224, 0.272831555105846, 
    0.161709939963884, 0.161709939963884, 0.0705363185891383, 
    0.0539908187360703, 0.045662586002321, 0.045662586002321, 
    0.0457607921272363, 0.0405033046723684, -0.0231644088974159, 
    -0.0331683127873594, 0.104584776054389, 0.310585940411996, 
    0.400546484806158, 0.381185618898762, 0.49589495687974, 0.654038934467795, 
    0.643727492704111, 0.695143210231344), ymax = c(1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
    1, 1.34866956511778, 1.34866956511778, 1.34866956511778, 
    1.34866956511778, 1.34866956511778, 1.34866956511778, 1.34095433041589, 
    1.34095433041589, 1.34095433041589, 1.6041933300953, 2.11974190959609, 
    2.11974190959609, 2.37605223427963, 2.67445205301881, 2.67445205301881, 
    2.831310148126, 2.831310148126, 2.831310148126, 2.79344549201264, 
    2.8859901023686, 3.10647878972174, 3.83829006003612, 3.83829006003612, 
    4.4627970147442, 4.6126758479306, 5.02100408066435, 5.02100408066435, 
    5.15423920787276, 5.95949669532763, 6.55649774223075, 6.69983497945403, 
    7.36208189061228, 8.22274739292134, 8.53278684852718, 9.35214771443457, 
    9.63743837645359, 10.6792943988655, 11.3562725072959, 11.7048567897687
    )), .Names = c("steps", "count", "meanval", "ymin", "ymax"
), row.names = c(NA, -100L), class = "data.frame"), layers = list(
    <environment>, <environment>, <environment>), scales = <environment>, 
    mapping = structure(list(x = steps), .Names = "x", class = "uneval"), 
    theme = structure(list(legend.position = "none"), .Names = "legend.position", class = c("theme", 
    "gg"), complete = FALSE, validate = FALSE), coordinates = <environment>, 
    facet = structure(list(shrink = TRUE), .Names = "shrink", class = c("null", 
    "facet")), plot_env = <environment>, labels = structure(list(
        x = "r", y = "count", ymax = "ymax", ymin = "ymin", alpha = "0.5"), .Names = c("x", 
    "y", "ymax", "ymin", "alpha"))), .Names = c("data", "layers", 
"scales", "mapping", "theme", "coordinates", "facet", "plot_env", 
"labels"), class = c("gg", "ggplot")))
4

0 回答 0