0
所以我和我的同事在R(使用管道:Package dplyr,magrittr)中製作了我的數據矩陣,並將其繪製在filled.contour圖中。但由於某種原因,它不會繪製我的最後兩點。R:填充輪廓圖不會繪製所有矩陣
有沒有人有解決這個問題?
這是我dput
我的數據集/矩陣:
structure(list(AvgDepth = c(5L, 5L, 15L, 5L, 15L, 25L, 5L, 15L,
25L, 35L, 5L, 15L, 25L, 35L, 5L, 15L, 25L, 35L, 45L, 5L, 15L,
25L, 35L, 45L, 55L, 5L, 15L, 25L, 35L, 45L, 55L, 65L, 5L, 15L,
25L, 35L, 45L, 55L, 65L, 75L, 5L, 15L, 25L, 35L, 45L, 55L, 65L,
75L, 85L, 95L), AvgMaxDepth = c(5L, 15L, 15L, 25L, 25L, 25L,
35L, 35L, 35L, 35L, 45L, 45L, 45L, 45L, 55L, 55L, 55L, 55L, 55L,
65L, 65L, 65L, 65L, 65L, 65L, 75L, 75L, 75L, 75L, 75L, 75L, 75L,
85L, 85L, 85L, 85L, 85L, 85L, 85L, 85L, 95L, 95L, 95L, 95L, 95L,
95L, 95L, 95L, 95L, 95L), MiddleOldG = c(-0.010339548,
-0.019087115, -0.013710817, -0.018843724, -0.016954714, -0.009270159,
-0.021369483, -0.020470118, -0.020793118, -0.038538718, -0.014960888,
-0.010406261, -0.014440231, -0.018794958, -0.020203279, -0.015599607,
-0.017050242, -0.024199387, -0.025290379, -0.026409047, -0.023564188,
-0.027233605, -0.031364833, -0.033557383, -0.036140136, -0.022472455,
-0.011018529, -0.01468673, -0.022262797, -0.027657312, -0.026680228,
-0.02738715, -0.025351831, -0.026051226, -0.021691668, -0.025787225,
-0.018350888, -0.019350486, -0.018076008, -0.011645933, -0.005070788,
-0.006843451, -0.001764863, -0.001371702, -0.002248032, -0.002476992,
0.00325166, 0.004070139, 0.033053363, 0.022264692), x = c(1,
1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3,
4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3,
4, 5, 6, 7, 8, 9, 10), y = c(1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5,
5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8,
9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
)), class = "data.frame", .Names = c("AvgDepth", "AvgMaxDepth",
"MiddleOldG", "x", "y"), row.names = c(NA,
-50L))
這裏的矩陣是什麼樣子:
http://i.stack.imgur.com/x6ngn.png
下面是代碼
library(colorspace)
library(dplyr)
library(magrittr)
Descent<-read.csv(file.choose())
attach(Descent)
summary(Descent)
Descent %<>% mutate(x = (AvgDepth + 5)/10, y = (AvgMaxDepth + 5)/10)
z = matrix(NA, ncol = 10, nrow = 10)
z.middle = Descent %>% select(x, y, MiddleOldG)
for (i in 1:nrow(z.middle)) z[z.middle[i,1],z.middle[i,2]] = z.middle[i,3]
filled.contour(x = seq(5, 95, by = 10), y = seq(5, 95, by = 10), z, color.palette=diverge_hsv, xlab="Depth (m)", ylab="Maximum Depth (m)", levels = pretty(c(-0.04,0.04),24))
但它不會繪製9,10和10,10數據點ts在矩陣中
它們應該在圖的右上角,但它們不是。
爲什麼它不繪製的最後兩點的任何想法?
這裏是數據集:https://docs.google.com/spreadsheets/d/13BJQ9-EXr2wu5tZNqXSzdbg_cLUjVw65W7yAAwydf_8/edit?usp=sharing
由於
如果你看看'填補。輪廓「,所以你應該找出失敗原因的描述。 –
@ 42-我一直在尋找,沒有結果 – LearningTheMacros
我誤解了這個問題,因爲你說要繪製filled.contour內的點。相反,你沒有注意到的原因是人們不願意在沒有易於剪切和粘貼的數據的情況下再現你的問題。沒有人可以導入該圖像。學習將dput(Descent)的結果發佈爲現有問題的編輯。 –