Cowplot 中的plot_clone 错误

2024-03-04

我正在尝试使用plot_grid在包owplot中制作2x2图。我不断收到错误消息:

plot_clone(plot) 中的错误:尝试应用非函数

我不知道如何纠正这个问题。起初我不确定 copplot 是否只能处理 1x2 或 2x1 布局,类似于您在这个小插曲 https://cran.r-project.org/web/packages/cowplot/vignettes/plot_grid.html。因此,按照接近尾声的示例,我尝试保存两对两个,然后使用plot_grid。但每当我运行该函数时,我都会收到相同的错误消息。

我的四个 ggplots 保存为:

> dput(plot.a)
structure(list(data = structure(list(bin = structure(1:20, .Label = c("1", 
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", 
"14", "15", "16", "17", "18", "19", "20"), class = "factor"), 
dist = c(2.72727272727273, 18.3333333333333, 29.53125, 39.1025641025641, 
49.5, 60, 69.6666666666667, 79.0606060606061, 89.6428571428571, 
100, 107.5, 117.888888888889, 129.047619047619, 140, 149.782608695652, 
160, 168.75, 177.083333333333, 187.5, 200), std.dist = c(-1.60612893947445, 
-1.30910466744194, -1.09597893826813, -0.913811722884859, 
-0.715921242615852, -0.516078698423106, -0.332096673610737, 
-0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 
1.00653116209305, 1.19271986786269, 1.38718362722209, 1.55371908071605, 
1.71232427451981, 1.91058076677452, 2.14848855748017), obs = c(0.268181818181818, 
0.425238095238095, 0.6328125, 0.546666666666667, 0.80125, 
0.832068965517241, 0.906666666666667, 0.874848484848485, 
0.764285714285714, 0.916458333333333, 1, 0.944444444444444, 
1, 1, 1, 1, 1, 1, 1, 1), mpred = c(0.388774380495604, 0.497341593391953, 
0.576647257194245, 0.641695739818402, 0.706912458033573, 
0.76509928057554, 0.810878009592326, 0.848307082818594, 0.882946297247916, 
0.909850599520384, 0.925472961630695, 0.943115230038192, 
0.95758533934757, 0.968299080735412, 0.975544279359121, 0.981373141486811, 
0.985217775779377, 0.988151202371436, 0.991013928856914, 
0.993559472422062), lci = c(0.297768163760385, 0.42059410960659, 
0.513948103151847, 0.587648581250763, 0.661468391191498, 
0.723357484486191, 0.771582331828126, 0.809426276300194, 
0.844627676773232, 0.872452498570834, 0.890204994397078, 
0.911051522523887, 0.928724877550503, 0.942952498677686, 
0.953383038475471, 0.9621, 0.96835, 0.973446874467174, 0.9786, 
0.9836), uci = c(0.483767440722556, 0.573009143094962, 0.637484434181386, 
0.691293140690589, 0.748919499311025, 0.804142486045091, 
0.84934716439577, 0.885493777505561, 0.917754641498512, 0.940889978796971, 
0.95374749869264, 0.967985138386314, 0.978485593963806, 0.985347498734588, 
0.989613043478261, 0.9928, 0.99475, 0.996091666666667, 0.99735, 
0.9983), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 
110, 120, 130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", 
"dist", "std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame"), layers = list(<environment>, <environment>, 
<environment>, <environment>, <environment>), scales = <S4 object of class structure("Scales", package = "ggplot2")>, 
mapping = structure(list(x = x), .Names = "x", class = "uneval"), 
theme = list(), coordinates = structure(list(limits = structure(list(
    x = NULL, y = NULL), .Names = c("x", "y"))), .Names = "limits", class = c("cartesian", 
"coord")), facet = structure(list(shrink = TRUE), .Names = "shrink", class = c("null", 
"facet")), plot_env = <environment>, labels = structure(list(
    x = "x", ymin = "lci", ymax = "uci", y = "uci"), .Names = c("x", 
"ymin", "ymax", "y"))), .Names = c("data", "layers", "scales", 
"mapping", "theme", "coordinates", "facet", "plot_env", "labels"
), class = c("gg", "ggplot"))

> dput(plot.b)
structure(list(data = structure(list(bin = structure(1:20, .Label = c("1", 
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", 
"14", "15", "16", "17", "18", "19", "20"), class = "factor"), 
dist = c(2.72727272727273, 18.3333333333333, 29.53125, 39.1025641025641, 
49.5, 60, 69.6666666666667, 79.0606060606061, 89.6428571428571, 
100, 107.5, 117.888888888889, 129.047619047619, 140, 149.782608695652, 
160, 168.75, 177.083333333333, 187.5, 200), std.dist = c(-1.60612893947445, 
-1.30910466744194, -1.09597893826813, -0.913811722884859, 
-0.715921242615852, -0.516078698423106, -0.332096673610737, 
-0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 
1.00653116209305, 1.19271986786269, 1.38718362722209, 1.55371908071605, 
1.71232427451981, 1.91058076677452, 2.14848855748017), obs = c(0.0909090909090909, 
0.0985714285714286, 0.0315625, 0.0751282051282051, 0.028, 
0.0293103448275862, 0.0333333333333333, 0.0106060606060606, 
0.0714285714285714, 0.00229166666666667, 0, 0.00277777777777778, 
0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.276177265460359, 0.209974580335731, 
0.170205040967226, 0.141375628420341, 0.114888871702638, 
0.0927755035971223, 0.0760669632294165, 0.0626412070343725, 
0.0502322659015645, 0.0404643884892086, 0.0346603179456435, 
0.0279245502708944, 0.022160834913022, 0.0176743725019984, 
0.014473212195461, 0.0117578479216627, 0.00986488669064748, 
0.00834929563349321, 0.0067862803157474, 0.00529717246203038
), lci = c(0.19062270150336, 0.15350824203276, 0.128925694286612, 
0.10867300133109, 0.0871838636807364, 0.0670572349380336, 
0.0515046182196629, 0.0387239876334207, 0.0279709435078909, 
0.0199986096822199, 0.0157738436198193, 0.0112862759966146, 
0.00792105787263693, 0.00547476100484075, 0.00395829271888495, 
0.00278909928468121, 0.00209050333490606, 0.00158626547219278, 
0.00111889275856179, 0.000737468674285579), uci = c(0.37243545256885, 
0.272010803390763, 0.214473820819953, 0.17632268171621, 0.144964749207079, 
0.120647489665425, 0.103803165916785, 0.0900475004082622, 
0.0768597211395678, 0.0657889969676395, 0.0593651891164288, 
0.05140562965974, 0.0440479874047032, 0.0374547496671013, 
0.0326573463604563, 0.0283994982438483, 0.0249099236720525, 
0.0220907957583452, 0.0190463443547909, 0.01613), x = c(0, 
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 
150, 160, 170, 180, 190)), .Names = c("bin", "dist", "std.dist", 
"obs", "mpred", "lci", "uci", "x"), row.names = c(NA, -20L), class = "data.frame"), 
layers = list(<environment>, <environment>, <environment>, 
    <environment>, <environment>), scales = <S4 object of class structure("Scales", package = "ggplot2")>, 
mapping = structure(list(x = x), .Names = "x", class = "uneval"), 
theme = list(), coordinates = structure(list(limits = structure(list(
    x = NULL, y = NULL), .Names = c("x", "y"))), .Names = "limits", class = c("cartesian", 
"coord")), facet = structure(list(shrink = TRUE), .Names = "shrink", class = c("null", 
"facet")), plot_env = <environment>, labels = structure(list(
    x = "x", ymin = "lci", ymax = "uci", y = "uci"), .Names = c("x", 
"ymin", "ymax", "y"))), .Names = c("data", "layers", "scales", 
"mapping", "theme", "coordinates", "facet", "plot_env", "labels"
), class = c("gg", "ggplot"))

> dput(plot.c)
structure(list(data = structure(list(bin = structure(1:20, .Label = c("1", 
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", 
"14", "15", "16", "17", "18", "19", "20"), class = "factor"), 
dist = c(2.72727272727273, 18.3333333333333, 29.53125, 39.1025641025641, 
49.5, 60, 69.6666666666667, 79.0606060606061, 89.6428571428571, 
100, 107.5, 117.888888888889, 129.047619047619, 140, 149.782608695652, 
160, 168.75, 177.083333333333, 187.5, 200), std.dist = c(-1.60612893947445, 
-1.30910466744194, -1.09597893826813, -0.913811722884859, 
-0.715921242615852, -0.516078698423106, -0.332096673610737, 
-0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 
1.00653116209305, 1.19271986786269, 1.38718362722209, 1.55371908071605, 
1.71232427451981, 1.91058076677452, 2.14848855748017), obs = c(0.136363636363636, 
0.224285714285714, 0.1746875, 0.180769230769231, 0.08, 0.0524137931034483, 
0.06, 0.0918181818181818, 0.128571428571429, 0.08125, 0, 
0.0527777777777778, 0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.396007183344234, 
0.323398427924327, 0.275767873201439, 0.23877806882699, 0.202648932853717, 
0.170561630695444, 0.144888476951772, 0.123223719933144, 
0.102255775950668, 0.0849707474020783, 0.074301175059952, 
0.0615282629451994, 0.0501849880095923, 0.0410420743405276, 
0.0343116945400202, 0.0284480003996803, 0.0242571770583533, 
0.0208352824074074, 0.0172327575939249, 0.0137187533972822
), lci = c(0.309108383852639, 0.259739964454443, 0.226331084336736, 
0.198126852675932, 0.168002492573431, 0.1387, 0.112832816960042, 
0.090929302258261, 0.0707525118106233, 0.0546067388110001, 
0.0456586166307923, 0.0349413825456728, 0.0259271742309591, 
0.0193719588008097, 0.0149584265465208, 0.0113157400820788, 
0.00895191986755036, 0.00713492400674309, 0.00532896603864423, 
0.00377012376932766), uci = c(0.489901697647913, 0.391021582366999, 
0.3273925733182, 0.281850059674837, 0.240157199858824, 0.2057, 
0.180443166234289, 0.159109689350491, 0.1395, 0.1227, 0.111566091657504, 
0.0979619976347301, 0.084907043339688, 0.0742617216260901, 
0.0655689139953165, 0.0568322234548294, 0.0501718975901771, 
0.0447513982066218, 0.0391577198298473, 0.0330701139149641
), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 
120, 130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", 
"dist", "std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame"), layers = list(<environment>, <environment>, 
<environment>, <environment>, <environment>), scales = <S4 object of class structure("Scales", package = "ggplot2")>, 
mapping = structure(list(x = x), .Names = "x", class = "uneval"), 
theme = list(), coordinates = structure(list(limits = structure(list(
    x = NULL, y = NULL), .Names = c("x", "y"))), .Names = "limits", class = c("cartesian", 
"coord")), facet = structure(list(shrink = TRUE), .Names = "shrink", class = c("null", 
"facet")), plot_env = <environment>, labels = structure(list(
    x = "x", ymin = "lci", ymax = "uci", y = "uci"), .Names = c("x", 
"ymin", "ymax", "y"))), .Names = c("data", "layers", "scales", 
"mapping", "theme", "coordinates", "facet", "plot_env", "labels"
), class = c("gg", "ggplot"))

> dput(plot.def)
structure(list(data = structure(list(bin = structure(1:20, .Label = c("1", 
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", 
"14", "15", "16", "17", "18", "19", "20"), class = "factor"), 
dist = c(2.72727272727273, 18.3333333333333, 29.53125, 39.1025641025641, 
49.5, 60, 69.6666666666667, 79.0606060606061, 89.6428571428571, 
100, 107.5, 117.888888888889, 129.047619047619, 140, 149.782608695652, 
160, 168.75, 177.083333333333, 187.5, 200), std.dist = c(-1.60612893947445, 
-1.30910466744194, -1.09597893826813, -0.913811722884859, 
-0.715921242615852, -0.516078698423106, -0.332096673610737, 
-0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 
1.00653116209305, 1.19271986786269, 1.38718362722209, 1.55371908071605, 
1.71232427451981, 1.91058076677452, 2.14848855748017), obs = c(0.504545454545455, 
0.251904761904762, 0.1609375, 0.197435897435897, 0.09075, 
0.0862068965517241, 0, 0.0227272727272727, 0.0357142857142857, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.545319024780176, 
0.385214215294431, 0.281065328986811, 0.207366167578758, 
0.14471123461231, 0.098486518784972, 0.0684568028244071, 
0.047804470120873, 0.0316512625042823, 0.0211158213429257, 
0.0158420865307754, 0.0105729330246914, 0.00686132620379887, 
0.00449120627498002, 0.00309464743440031, 0.0020996685891287, 
0.0015159548421263, 0.00111107593891553, 0.00075490557773781, 
0.000474568535971223), lci = c(0.417808749228615, 0.297629056710751, 
0.221329055036562, 0.15937986030437, 0.10455, 0.0642914930179108, 
0.0397254303811289, 0.0241381409954533, 0.013732639580488, 
0.00773819374865001, 0.00515355573824683, 0.00290910838994936, 
0.00156671161936531, 0.000857607184772948, 0.000498446746117533, 
0.000280876962784603, 0.000172977492684956, 0.000109686646512733, 
6.20418685828108e-05, 3.07803199924385e-05), uci = c(0.671203738070494, 
0.476831664841552, 0.345660702829477, 0.257423105479597, 
0.186359497668321, 0.137389854806939, 0.102873333333333, 
0.0774201540832578, 0.0559549705034255, 0.0411089951472052, 
0.032910549513622, 0.0240294378945808, 0.017022668627324, 
0.012113724270874, 0.00894324443701978, 0.00658660181431583, 
0.00506777502183314, 0.00392338811324972, 0.00284237332468719, 
0.00192574352635954), x = c(0, 10, 20, 30, 40, 50, 60, 70, 
80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", 
"dist", "std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame"), layers = list(<environment>, <environment>, 
<environment>, <environment>, <environment>), scales = <S4 object of class structure("Scales", package = "ggplot2")>, 
mapping = structure(list(x = x), .Names = "x", class = "uneval"), 
theme = list(), coordinates = structure(list(limits = structure(list(
    x = NULL, y = NULL), .Names = c("x", "y"))), .Names = "limits", class = c("cartesian", 
"coord")), facet = structure(list(shrink = TRUE), .Names = "shrink", class = c("null", 
"facet")), plot_env = <environment>, labels = structure(list(
    x = "x", ymin = "lci", ymax = "uci", y = "uci"), .Names = c("x", 
"ymin", "ymax", "y"))), .Names = c("data", "layers", "scales", 
"mapping", "theme", "coordinates", "facet", "plot_env", "labels"
), class = c("gg", "ggplot"))

我的牛图代码如下:

require(cowplot)
theme_set(theme_cowplot(font_size=12)) # reduce default font size
top_row <- plot_grid(plot.a, plot.b, labels=c("A","B"))
bottom_row <-plot_grid(plot.c, plot.def, labels=c("C","D"))
plot_grid(top_row,bottom_row)

以前有人遇到过并解决过这个问题吗?为了确保所有系统要求正确,我更新到 R 版本 3.3.1,我在 Windows 10 计算机上从 RStudio 运行该版本。

EDIT

您应该能够将此代码复制并粘贴到控制台。这将创建我的四个数据框,将它们保存为 ggplots,并执行plot_grid。当您独立运行这四个 ggplot 时,它们工作得很好。

pd.a.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.268181818181818, 
0.425238095238095, 0.6328125, 0.546666666666667, 0.80125, 0.832068965517241, 
0.906666666666667, 0.874848484848485, 0.764285714285714, 0.916458333333333, 
1, 0.944444444444444, 1, 1, 1, 1, 1, 1, 1, 1), mpred = c(0.388774380495604, 
0.497341593391953, 0.576647257194245, 0.641695739818402, 0.706912458033573, 
0.76509928057554, 0.810878009592326, 0.848307082818594, 0.882946297247916, 
0.909850599520384, 0.925472961630695, 0.943115230038192, 0.95758533934757, 
0.968299080735412, 0.975544279359121, 0.981373141486811, 0.985217775779377, 
0.988151202371436, 0.991013928856914, 0.993559472422062), lci = c(0.297768163760385, 
0.42059410960659, 0.513948103151847, 0.587648581250763, 0.661468391191498, 
0.723357484486191, 0.771582331828126, 0.809426276300194, 0.844627676773232, 
0.872452498570834, 0.890204994397078, 0.911051522523887, 0.928724877550503, 
0.942952498677686, 0.953383038475471, 0.9621, 0.96835, 0.973446874467174, 
0.9786, 0.9836), uci = c(0.483767440722556, 0.573009143094962, 
0.637484434181386, 0.691293140690589, 0.748919499311025, 0.804142486045091, 
0.84934716439577, 0.885493777505561, 0.917754641498512, 0.940889978796971, 
0.95374749869264, 0.967985138386314, 0.978485593963806, 0.985347498734588, 
0.989613043478261, 0.9928, 0.99475, 0.996091666666667, 0.99735, 
0.9983), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 
120, 130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", "dist", 
"std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame")

pd.b.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.0909090909090909, 
0.0985714285714286, 0.0315625, 0.0751282051282051, 0.028, 0.0293103448275862, 
0.0333333333333333, 0.0106060606060606, 0.0714285714285714, 0.00229166666666667, 
0, 0.00277777777777778, 0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.276177265460359, 
0.209974580335731, 0.170205040967226, 0.141375628420341, 0.114888871702638, 
0.0927755035971223, 0.0760669632294165, 0.0626412070343725, 0.0502322659015645, 
0.0404643884892086, 0.0346603179456435, 0.0279245502708944, 0.022160834913022, 
0.0176743725019984, 0.014473212195461, 0.0117578479216627, 0.00986488669064748, 
0.00834929563349321, 0.0067862803157474, 0.00529717246203038), 
lci = c(0.19062270150336, 0.15350824203276, 0.128925694286612, 
0.10867300133109, 0.0871838636807364, 0.0670572349380336, 
0.0515046182196629, 0.0387239876334207, 0.0279709435078909, 
0.0199986096822199, 0.0157738436198193, 0.0112862759966146, 
0.00792105787263693, 0.00547476100484075, 0.00395829271888495, 
0.00278909928468121, 0.00209050333490606, 0.00158626547219278, 
0.00111889275856179, 0.000737468674285579), uci = c(0.37243545256885, 
0.272010803390763, 0.214473820819953, 0.17632268171621, 0.144964749207079, 
0.120647489665425, 0.103803165916785, 0.0900475004082622, 
0.0768597211395678, 0.0657889969676395, 0.0593651891164288, 
0.05140562965974, 0.0440479874047032, 0.0374547496671013, 
0.0326573463604563, 0.0283994982438483, 0.0249099236720525, 
0.0220907957583452, 0.0190463443547909, 0.01613), x = c(0, 
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 
150, 160, 170, 180, 190)), .Names = c("bin", "dist", "std.dist", 
"obs", "mpred", "lci", "uci", "x"), row.names = c(NA, -20L), class =     "data.frame")

pd.c.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.136363636363636, 
0.224285714285714, 0.1746875, 0.180769230769231, 0.08, 0.0524137931034483, 
0.06, 0.0918181818181818, 0.128571428571429, 0.08125, 0, 0.0527777777777778, 
0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.396007183344234, 0.323398427924327, 
0.275767873201439, 0.23877806882699, 0.202648932853717, 0.170561630695444, 
0.144888476951772, 0.123223719933144, 0.102255775950668, 0.0849707474020783, 
0.074301175059952, 0.0615282629451994, 0.0501849880095923, 0.0410420743405276, 
0.0343116945400202, 0.0284480003996803, 0.0242571770583533, 0.0208352824074074, 
0.0172327575939249, 0.0137187533972822), lci = c(0.309108383852639, 
0.259739964454443, 0.226331084336736, 0.198126852675932, 0.168002492573431, 
0.1387, 0.112832816960042, 0.090929302258261, 0.0707525118106233, 
0.0546067388110001, 0.0456586166307923, 0.0349413825456728, 0.0259271742309591, 
0.0193719588008097, 0.0149584265465208, 0.0113157400820788, 0.00895191986755036, 
0.00713492400674309, 0.00532896603864423, 0.00377012376932766
), uci = c(0.489901697647913, 0.391021582366999, 0.3273925733182, 
0.281850059674837, 0.240157199858824, 0.2057, 0.180443166234289, 
0.159109689350491, 0.1395, 0.1227, 0.111566091657504, 0.0979619976347301, 
0.084907043339688, 0.0742617216260901, 0.0655689139953165, 0.0568322234548294, 
0.0501718975901771, 0.0447513982066218, 0.0391577198298473, 0.0330701139149641
), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 
130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", "dist", 
"std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame")

pd.def.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.504545454545455, 
0.251904761904762, 0.1609375, 0.197435897435897, 0.09075, 0.0862068965517241, 
0, 0.0227272727272727, 0.0357142857142857, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0), mpred = c(0.545319024780176, 0.385214215294431, 
0.281065328986811, 0.207366167578758, 0.14471123461231, 0.098486518784972, 
0.0684568028244071, 0.047804470120873, 0.0316512625042823, 0.0211158213429257, 
0.0158420865307754, 0.0105729330246914, 0.00686132620379887, 
0.00449120627498002, 0.00309464743440031, 0.0020996685891287, 
0.0015159548421263, 0.00111107593891553, 0.00075490557773781, 
0.000474568535971223), lci = c(0.417808749228615, 0.297629056710751, 
0.221329055036562, 0.15937986030437, 0.10455, 0.0642914930179108, 
0.0397254303811289, 0.0241381409954533, 0.013732639580488, 0.00773819374865001, 
0.00515355573824683, 0.00290910838994936, 0.00156671161936531, 
0.000857607184772948, 0.000498446746117533, 0.000280876962784603, 
0.000172977492684956, 0.000109686646512733, 6.20418685828108e-05, 
3.07803199924385e-05), uci = c(0.671203738070494, 0.476831664841552, 
0.345660702829477, 0.257423105479597, 0.186359497668321, 0.137389854806939, 
0.102873333333333, 0.0774201540832578, 0.0559549705034255, 0.0411089951472052, 
0.032910549513622, 0.0240294378945808, 0.017022668627324, 0.012113724270874, 
0.00894324443701978, 0.00658660181431583, 0.00506777502183314, 
0.00392338811324972, 0.00284237332468719, 0.00192574352635954
), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 
130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", "dist", 
"std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame")

require(gglot2)

plot.a<-ggplot(pd.a.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

plot.b<-ggplot(pd.b.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

plot.c<-ggplot(pd.c.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

plot.def<-ggplot(pd.def.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

require(cowplot)
theme_set(theme_cowplot(font_size=12)) # reduce default font size
top_row <- plot_grid(plot.a, plot.b, labels=c("A","B"))
bottom_row <-plot_grid(plot.c, plot.def, labels=c("C","D"))
plot_grid(top_row,bottom_row)

EDIT 2

我还刚刚意识到,当我返回并尝试仅可视化其中一个图(例如,plot.b)时,我现在收到错误消息并且无法生成它,而每个图在尝试之前都可以正常工作来安排它们使用plot_grid.


这段代码:

pd.a.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.268181818181818, 
0.425238095238095, 0.6328125, 0.546666666666667, 0.80125, 0.832068965517241, 
0.906666666666667, 0.874848484848485, 0.764285714285714, 0.916458333333333, 
1, 0.944444444444444, 1, 1, 1, 1, 1, 1, 1, 1), mpred = c(0.388774380495604, 
0.497341593391953, 0.576647257194245, 0.641695739818402, 0.706912458033573, 
0.76509928057554, 0.810878009592326, 0.848307082818594, 0.882946297247916, 
0.909850599520384, 0.925472961630695, 0.943115230038192, 0.95758533934757, 
0.968299080735412, 0.975544279359121, 0.981373141486811, 0.985217775779377, 
0.988151202371436, 0.991013928856914, 0.993559472422062), lci = c(0.297768163760385, 
0.42059410960659, 0.513948103151847, 0.587648581250763, 0.661468391191498, 
0.723357484486191, 0.771582331828126, 0.809426276300194, 0.844627676773232, 
0.872452498570834, 0.890204994397078, 0.911051522523887, 0.928724877550503, 
0.942952498677686, 0.953383038475471, 0.9621, 0.96835, 0.973446874467174, 
0.9786, 0.9836), uci = c(0.483767440722556, 0.573009143094962, 
0.637484434181386, 0.691293140690589, 0.748919499311025, 0.804142486045091, 
0.84934716439577, 0.885493777505561, 0.917754641498512, 0.940889978796971, 
0.95374749869264, 0.967985138386314, 0.978485593963806, 0.985347498734588, 
0.989613043478261, 0.9928, 0.99475, 0.996091666666667, 0.99735, 
0.9983), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 
120, 130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", "dist", 
"std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame")

pd.b.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.0909090909090909, 
0.0985714285714286, 0.0315625, 0.0751282051282051, 0.028, 0.0293103448275862, 
0.0333333333333333, 0.0106060606060606, 0.0714285714285714, 0.00229166666666667, 
0, 0.00277777777777778, 0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.276177265460359, 
0.209974580335731, 0.170205040967226, 0.141375628420341, 0.114888871702638, 
0.0927755035971223, 0.0760669632294165, 0.0626412070343725, 0.0502322659015645, 
0.0404643884892086, 0.0346603179456435, 0.0279245502708944, 0.022160834913022, 
0.0176743725019984, 0.014473212195461, 0.0117578479216627, 0.00986488669064748, 
0.00834929563349321, 0.0067862803157474, 0.00529717246203038), 
lci = c(0.19062270150336, 0.15350824203276, 0.128925694286612, 
0.10867300133109, 0.0871838636807364, 0.0670572349380336, 
0.0515046182196629, 0.0387239876334207, 0.0279709435078909, 
0.0199986096822199, 0.0157738436198193, 0.0112862759966146, 
0.00792105787263693, 0.00547476100484075, 0.00395829271888495, 
0.00278909928468121, 0.00209050333490606, 0.00158626547219278, 
0.00111889275856179, 0.000737468674285579), uci = c(0.37243545256885, 
0.272010803390763, 0.214473820819953, 0.17632268171621, 0.144964749207079, 
0.120647489665425, 0.103803165916785, 0.0900475004082622, 
0.0768597211395678, 0.0657889969676395, 0.0593651891164288, 
0.05140562965974, 0.0440479874047032, 0.0374547496671013, 
0.0326573463604563, 0.0283994982438483, 0.0249099236720525, 
0.0220907957583452, 0.0190463443547909, 0.01613), x = c(0, 
10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 
150, 160, 170, 180, 190)), .Names = c("bin", "dist", "std.dist", 
"obs", "mpred", "lci", "uci", "x"), row.names = c(NA, -20L), class =     "data.frame")

pd.c.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.136363636363636, 
0.224285714285714, 0.1746875, 0.180769230769231, 0.08, 0.0524137931034483, 
0.06, 0.0918181818181818, 0.128571428571429, 0.08125, 0, 0.0527777777777778, 
0, 0, 0, 0, 0, 0, 0, 0), mpred = c(0.396007183344234, 0.323398427924327, 
0.275767873201439, 0.23877806882699, 0.202648932853717, 0.170561630695444, 
0.144888476951772, 0.123223719933144, 0.102255775950668, 0.0849707474020783, 
0.074301175059952, 0.0615282629451994, 0.0501849880095923, 0.0410420743405276, 
0.0343116945400202, 0.0284480003996803, 0.0242571770583533, 0.0208352824074074, 
0.0172327575939249, 0.0137187533972822), lci = c(0.309108383852639, 
0.259739964454443, 0.226331084336736, 0.198126852675932, 0.168002492573431, 
0.1387, 0.112832816960042, 0.090929302258261, 0.0707525118106233, 
0.0546067388110001, 0.0456586166307923, 0.0349413825456728, 0.0259271742309591, 
0.0193719588008097, 0.0149584265465208, 0.0113157400820788, 0.00895191986755036, 
0.00713492400674309, 0.00532896603864423, 0.00377012376932766
), uci = c(0.489901697647913, 0.391021582366999, 0.3273925733182, 
0.281850059674837, 0.240157199858824, 0.2057, 0.180443166234289, 
0.159109689350491, 0.1395, 0.1227, 0.111566091657504, 0.0979619976347301, 
0.084907043339688, 0.0742617216260901, 0.0655689139953165, 0.0568322234548294, 
0.0501718975901771, 0.0447513982066218, 0.0391577198298473, 0.0330701139149641
), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 
130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", "dist", 
"std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame")

pd.def.agg <- structure(list(bin = structure(1:20, .Label = c("1", "2", "3", 
"4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", 
"16", "17", "18", "19", "20"), class = "factor"), dist = c(2.72727272727273, 
18.3333333333333, 29.53125, 39.1025641025641, 49.5, 60, 69.6666666666667, 
79.0606060606061, 89.6428571428571, 100, 107.5, 117.888888888889, 
129.047619047619, 140, 149.782608695652, 160, 168.75, 177.083333333333, 
187.5, 200), std.dist = c(-1.60612893947445, -1.30910466744194, 
-1.09597893826813, -0.913811722884859, -0.715921242615852, -0.516078698423106, 
-0.332096673610737, -0.153305364231945, 0.0481026338217207, 0.245226231834973, 
0.387970906258363, 0.585698714533726, 0.798078621665245, 1.00653116209305, 
1.19271986786269, 1.38718362722209, 1.55371908071605, 1.71232427451981, 
1.91058076677452, 2.14848855748017), obs = c(0.504545454545455, 
0.251904761904762, 0.1609375, 0.197435897435897, 0.09075, 0.0862068965517241, 
0, 0.0227272727272727, 0.0357142857142857, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0), mpred = c(0.545319024780176, 0.385214215294431, 
0.281065328986811, 0.207366167578758, 0.14471123461231, 0.098486518784972, 
0.0684568028244071, 0.047804470120873, 0.0316512625042823, 0.0211158213429257, 
0.0158420865307754, 0.0105729330246914, 0.00686132620379887, 
0.00449120627498002, 0.00309464743440031, 0.0020996685891287, 
0.0015159548421263, 0.00111107593891553, 0.00075490557773781, 
0.000474568535971223), lci = c(0.417808749228615, 0.297629056710751, 
0.221329055036562, 0.15937986030437, 0.10455, 0.0642914930179108, 
0.0397254303811289, 0.0241381409954533, 0.013732639580488, 0.00773819374865001, 
0.00515355573824683, 0.00290910838994936, 0.00156671161936531, 
0.000857607184772948, 0.000498446746117533, 0.000280876962784603, 
0.000172977492684956, 0.000109686646512733, 6.20418685828108e-05, 
3.07803199924385e-05), uci = c(0.671203738070494, 0.476831664841552, 
0.345660702829477, 0.257423105479597, 0.186359497668321, 0.137389854806939, 
0.102873333333333, 0.0774201540832578, 0.0559549705034255, 0.0411089951472052, 
0.032910549513622, 0.0240294378945808, 0.017022668627324, 0.012113724270874, 
0.00894324443701978, 0.00658660181431583, 0.00506777502183314, 
0.00392338811324972, 0.00284237332468719, 0.00192574352635954
), x = c(0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 
130, 140, 150, 160, 170, 180, 190)), .Names = c("bin", "dist", 
"std.dist", "obs", "mpred", "lci", "uci", "x"), row.names = c(NA, 
-20L), class = "data.frame")

require(cowplot)

plot.a<-ggplot(pd.a.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

plot.b<-ggplot(pd.b.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

plot.c<-ggplot(pd.c.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

plot.def<-ggplot(pd.def.agg, aes(x=x)) +
geom_ribbon(aes(ymin=lci,ymax=uci), alpha=0.6, fill="grey70") +
geom_line(aes(y=uci), linetype=2) +
geom_line(aes(y=lci), linetype=2) +
geom_line(aes(y=mpred)) +
geom_point(aes(y=obs), size=3)

theme_set(theme_cowplot(font_size=12)) # reduce default font size
plot_grid(plot.a, plot.b, plot.c, plot.def, labels="AUTO")

generates this output: enter image description here

我不知道你为什么遇到问题。

这是我正在使用的包:

> getRversion()
[1] ‘3.3.1’
> packageVersion("ggplot2")
[1] ‘2.1.0’
> packageVersion("cowplot")
[1] ‘0.6.3’

请注意,在您粘贴的最后一个代码示例中,您编写了require(gglot2)代替require(ggplot2),这可能可以解释您遇到的一些问题。另外,没有必要要求cowplot and ggplot2分别地,cowplot将加载ggplot2.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Cowplot 中的plot_clone 错误 的相关文章

  • 在 R 中,如何将 SpatialPolygons* 转换为地图对象

    我正在尝试利用ProportionalSymbolMap在此定义的地图JSS论文 http www jstatsoft org v15 i05 为了绘制比例符号 我首先需要一个地图类的对象 The methods http www ncea
  • 如何更新 R 中的包?

    我想将一个 R 包升级到已经可用的新版本 我试过 update packages c R2jags 但它什么也没做 控制台上没有输出 没有错误 什么也没有 我使用了相同的语法install packages但也许我做错了什么 我一直在看 u
  • 在 r 中的字符串内循环以输出具有向量化值的表达式

    示例数据 gt DF A B C 1 11 22 88 2 11 22 47 3 2 30 21 4 3 30 21 gt r 1 A A i B B i A A i C C i 3 B B i C C i A A i B B i C C
  • R 的 read.csv 在第一列名称前面加上垃圾文本[重复]

    这个问题在这里已经有答案了 我已将数据从 SQL Server Management Studio 中的结果网格导出到 csv 文件 csv 文件看起来正确 但是当我使用 read csv 将数据读入 R 数据帧时 第一个列名称前面带有 如
  • 如何在 R 中为所有plot.default、plot 或lines 调用设置默认颜色

    为了简化我的日常 R 交互 我想为所有绘图设置默认颜色 例如 假设我想要用红线绘制所有绘图 例如在 gnuplot 中 到目前为止 这是我的 Rprofile 的片段 setHook packageEvent grDevices onLoa
  • 将 12 小时字符时间转换为 24 小时

    我有一个包含字符格式时间的数据集 我试图将其从 12 小时格式转换为 24 小时格式 我做了一些搜索 但我发现的所有内容似乎都假设字符已经采用 24 小时格式 这是我工作时的一个例子 times lt c 9 06 AM 4 42 PM 3
  • geom_polygon 的渐变填充

    此代码生成一个包含 3 个多边形的图表 我正在创建一个显示 3 个多边形的图表 如果有更好的方法来绘制多边形 我不太感兴趣 实际上这些多边形代表事件 并且这些事件有一个持续时间 首先 我感兴趣的是使用渐变填充每个多边形的可能性 librar
  • 安装 gplots 时出错

    我正在 OSX v 10 9 2 上运行 R v 3 0 3 当尝试使用以下命令在 R studio 中安装 gplots 包时 出现错误 gt library gplots Error in library gplots there is
  • R:中断 for 循环

    你能确认下一个break是否取消了内部for循环吗 for out in 1 n old id velho lt old table df id out for in in 1 n id novo lt new table df ID in
  • 使用 ggplot 添加到投影地图时 R 饼图扭曲

    我想使用 ggplot 将饼图绘制到投影地图上 然而 饼图可能由于投影而变得扭曲 有谁知道如何在不变形的情况下绘制饼图 示例代码如下 谢谢 lib c ggplot2 scatterpie lapply lib library charac
  • ess-rdired:我收到此错误“现在没有 ESS 进程与此缓冲区关联”

    To use ess rdired为了浏览对象 我按照 ESS 手册并将以下内容添加到我的 emacs autoload ess rdired ess rdired View R objects in a dired like buffer
  • 无效的命令名称“tk_chooseDirectory”错误

    我使用 bioconductor 进行 WES 管道 并使用 tk choose dir 选择用户存储输入文件的目录 并将其存储以供进一步使用 这里是命令行 library tcltk dataDir lt dirname tk choos
  • 将文件夹中的多个 csv 文件读取到 R 中的单个数据帧中[重复]

    这个问题在这里已经有答案了 我有一个包含 332 个 csv 文件的文件夹 文件名称如下 001 csv 002 csv 003 csv 330 csv 331 csv 332 csv 所有文件都具有相同数量的变量和相同的格式 我需要读取一
  • 如何更改 r 中的树状图标签

    我在 R 中有一个树形图 它基于使用 hclust 的分层聚类 我正在对不同颜色的标签进行着色 但是当我尝试使用以下命令更改树图的标签 集群所基于的数据帧的行 时dendrogram dendrogram gt set labels dat
  • 从受密码保护的站点读取信息

    我一直在 R 教程中使用 readLines 从网站上抓取信息 我现在希望从我自己的网站提取数据 特别是 awstats 数据 但是该域受密码保护 有没有一种方法可以通过用户名和密码传递我需要的特定 awstats 数据的 url url
  • 如何在R中将英尺转换为厘米?

    我得到了一个高度的字符向量 如下所示 859 5 10 5 8 5 11 6 0 5 10 6 2 5 11 6 2 6 2 5 7 5 9 5 7 6 1 6 0 5 11 6 0 6 5 6 1 6 1 5 10 5 11 5 11 6
  • 正则表达式提取美国邮政编码,但不提取假代码

    使用 XML 包和 XPath 从网站上抓取地址 有时我只能得到一个嵌入了我想要的邮政编码的字符串 提取邮政编码很简单 但有时会显示其他五位数字的字符串 以下是 df 中问题的一些变体 zips lt data frame id seq 1
  • XLConnect 无法确定 JAVA_HOME 错误

    感谢您的帮助 我正在尝试运行 XLconnect 但收到此错误消息 gt library XLConnect lib loc C Users 1144143929 Documents R win library 2 15 Error onL
  • 使用神经网络包进行多项分类

    这个问题应该很简单 但文档没有帮助 我正在使用 R 我必须使用neuralnet多项式分类问题的包 所有示例均针对二项式或线性输出 我可以使用二项式输出进行一些一对一的实现 但我相信我应该能够通过使用 3 个单元作为输出层来做到这一点 其中
  • R 中的点图每行有多个值

    我有以下 R 输入文件 car 1 car 2 car 3 car2 1 car2 2 car2 3 然后 我使用以下命令来绘制图表 autos data 点图 autos data V2 autos data V1 但这将每个汽车和 ca

随机推荐