I have to sort the x vector of my contour plot, because the values are not continuously ascending, but this means that the values will loose connection to the corresponding values of the z matrix and i have no clue how to do it. how can i do it? is there maybe a way that the values can sort automatically?
y(1:35):
31.42 47.42 63.42 79.42 95.42 111.42 127.42 143.42 159.42 175.42 191.42 207.42 223.42 239.42 255.42 271.42 287.42 303.42 319.42 335.42 351.42 367.42 383.42 399.42
415.42 431.42 447.42 463.42 479.42 495.42 511.42 527.42 543.42 559.42 575.42
x(1:11):
15.87267 15.87194 15.83458 15.78981 15.78705 15.78702 15.78932 15.78702 15.75134 15.70933 15.70172
z(1:35,1:11):
http://imgur.com/BBG79up&qURrN8T
http://imgur.com/BBG79up&qURrN8T#1
Asked
Active
Viewed 128 times
-3

Geht-das
- 3
- 3
-
It would be easier to help you if you provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – MrFlick Apr 19 '15 at 15:53
-
Yes sorry, i was caught up, updated example – Geht-das Apr 19 '15 at 16:31
2 Answers
0
Not sure what you're doing with the y vector, but a quick solution would be to merge them together, then sort, then extract.
x <- runif(10, min = 0, max = 100)
z <- replicate(10, runif(10, min = 0, max = 100))
x_z <- cbind(x, z)
sorted_x_z <- x_z[order(x_z[,1]), ]
x <- sorted_x_z[,1]
z <- sorted_x_z[, 2:11]

goodtimeslim
- 880
- 7
- 13