R -3D色带图的单列



我能够为矩阵创建ribbon3d图,该矩阵的尺寸大于1的行和列。当一个维度之一为1时,我会遇到问题。这意味着如果我有12行和一个列,那么我的代码会出现错误。需要帮助解决这种情况。

表的样本数据如下:

    structure(c(3, 4, 2, 2, 9, 6, 6, 7, 8, 10, 11), .Dim = c(1L, 
11L), .Dimnames = list("Fruits and nuts (excluding oil nuts), fresh or dried", 
    c("2005", "2006", "2007", "2008", "2009", "2010", "2011", 
    "2012", "2013", "2014", "2015")))

用于图的代码如下:

library(plot3D)
ribbon3D(x = 1:nrow(rs12), y = 1:ncol(rs12), z = rs12, scale = T, expand = .2, bty = "b", along = "y",  
         colvar = rs12, colkey = F, border = "black", shade = 0.1, 
         theta = -50, phi = 40, space = .5, d = 2, 
         curtain = T, xlab = "", ylab = "", zlab = "", main = "Pakistan's Exports to Russia", 
         cex.axis = 0.000000000001, box = F)

对于那些对其对矩阵的工作方式感兴趣的人大于1。这是示例数据。但是,在代码中将矩阵名称从rs12更改为tf12。通过在上述示例上运行上述代码的错误是这样,Error in persp.default(plist$xlim, plist$ylim, z = matrix(nrow = 2, ncol = 2, : increasing 'x' and 'y' values expected

dput(tf12)
structure(c(18, 36, 18, 39, 41, 18, 18, 18, 18, 36, 37, 18, 38, 
18, 18, 18, 40, 18, 18, 17, 36, 17, 39, 41, 17, 17, 17, 34, 38, 
36, 17, 34, 17, 17, 17, 40, 17, 17, 16, 38, 34, 40, 41, 16, 16, 
16, 16, 36, 36, 16, 34, 34, 34, 16, 39, 16, 16, 32, 40, 32, 40, 
41, 32, 32, 32, 14, 36, 36, 14, 14, 32, 32, 14, 38, 14, 14, 16, 
38, 33, 39, 41, 33, 16, 33, 33, 37, 36, 16, 33, 16, 16, 16, 40, 
16, 16, 14, 39, 31, 40, 41, 31, 31, 31, 31, 37, 36, 31, 14, 31, 
14, 31, 38, 14, 31, 30, 37, 30, 39, 41, 36, 13, 30, 30, 38, 30, 
30, 30, 30, 30, 30, 40, 13, 13, 15, 38, 32, 39, 41, 32, 15, 15, 
32, 38, 32, 32, 15, 32, 36, 15, 40, 15, 15, 15, 38, 32, 39, 41, 
36, 15, 15, 32, 38, 32, 32, 15, 15, 32, 15, 40, 32, 15, 15, 38, 
32, 39, 41, 36, 15, 15, 32, 32, 32, 36, 15, 32, 36, 15, 40, 15, 
15, 16, 38, 34, 39, 41, 37, 16, 16, 34, 16, 34, 16, 16, 34, 34, 
16, 40, 16, 16), .Dim = c(19L, 11L), .Dimnames = list(c("Pig iron & spiegeleisen, sponge iron, powder & granu", 
"Ores and concentrates of base metals, n.e.s.", "Waste, parings and scrap, of plastics", 
"Leather", "Textile yarn", "Stone, sand and gravel", "Fish, dried, salted or in brine; smoked fish", 
"Copper", "Non-ferrous base metal waste and scrap, n.e.s.", "Cotton", 
"Fish, fresh (live or dead), chilled or frozen", "Feeding stuff for animals (no unmilled cereals)", 
"Carboxylic acids, anhydrides, halides, per.; derivati.", "Crustaceans, mollusks and aquatic invertebrates", 
"Crude vegetable materials, n.e.s.", "Polymers of ethylene, in primary forms", 
"Cotton fabrics, woven", "Other crude minerals", "Ships, boats & floating structures"
), c("2005", "2006", "2007", "2008", "2009", "2010", "2011", 
"2012", "2013", "2014", "2015")))

这是由 ribbon3D中的一个错误引起的:它是矩阵的子集,但不告诉r作为矩阵保留,因此它变成了向量,此后情况很差。

您可以使用fix()函数自己修复该错误来编辑并创建本地副本,但是您最终会出现不同的错误,这可能是其他地方同一问题引起的。

我建议您有两种选择:

  1. 花一些时间追踪并解决所有这些问题。这是学习在R中进行调试的好机会,但需要一段时间。将它们全部修复后,将必要更改的列表发送给plot3D软件包的维护者。

  2. 写信给维护者,包括您可重复的例子,并希望她有兴趣和时间来解决这个问题。

相关内容

  • 没有找到相关文章

最新更新