As others have said, z[z[, 1] < 0, ] does it. Just in case
you're wondering why your subset command won't work,
str() is your friend (as is so often the case):
str(z)
str(as.data.frame(z)) ## (I don't think that R has 'as.data.set')
So z is a matrix with column *names* "x1", etc;
as.data.frame(
Hi:
> z = matrix(rnorm(n*m),n,m,dimnames =list(rnames,cnames))
> z
x1 x2 x3 x4 x5
1 -0.3942900 -0.61202639 -1.804958629 -0.1351786 -1.27659221
2 -0.0593134 0.34111969 1.465554862 1.1780870 -0.57326541
3 1.1000254 -1.12936310 0.153253338 -1.523
Try this:
z[z[,1] < 0,]
On Tue, Feb 9, 2010 at 6:12 PM, DonDiego wrote:
>
> Hi,
>
> I have a matrix of data values like the example bellow. I would like to
> extract a subset of the matrix for the values where the first column is
> negative. I am using the subset function. However, I am getting
3 matches
Mail list logo