所以我的同事和我在R(使用管道:包dplyr,magrittr)中创建了我的数据矩阵,并将其绘制在一个fill.contour图中。但由于某种原因,它不会绘制我的最后两点。
有没有人对此有解决方法?
以下是我的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个数据点
它们应该位于情节的右上角,但它们不是。
为什么它没有绘制最后两点的任何想法?
以下是数据集:https://docs.google.com/spreadsheets/d/13BJQ9-EXr2wu5tZNqXSzdbg_cLUjVw65W7yAAwydf_8/edit?usp=sharing
由于