Displaying 2 results from an estimated 2 matches for "ofvalu".
Did you mean:
fval
2008 Mar 09
2
question about matrix one column values matching a vector of values
Hi,
I have a matrix
a = matrix (1:16, 4, 4)
b = c (2,3)
I want to find out which rows of a, where a[,1] equals any values of b?
I know that if b is only one value, e.g, b=2, then what I want is a[a[,1] == 2,]
But what about if it is not one value but a vector of values?
Thanks much in advance.
--
Waverley @ Palo Alto
2009 Jul 03
0
Presumably simple question about sorting/ordering
...vector, and reorder it to match with an erratic sequence of x,y coordinates. Here's an example that shows what I want and how close I've got (but for some reason my mind just can't get the final step at the moment!):
#Define a grid:
xy100 <- expand.grid(1:10, 1:10)
# Define a matrix ofvalues
mat <- matrix(log(xy100[,1]) * log(xy100[,2])+1, ncol = 10)/2
#Plot some the matrix with image and the same data as xy plot:
par(mfrow = c(2,2))
image(mat)
plot(xy100, cex = c(mat), pch = 20)
#define the subset of coordinates I'm interested in:
shortXY <- expand.grid(1:5, 1:5)
#and sh...