Hi Ajay,

In the first case, you need "==" instead of "=" :

R> mtcars[ rownames(mtcars) == "Valiant", ]
 mpg cyl disp  hp drat   wt  qsec vs am gear carb
Valiant 18.1   6  225 105 2.76 3.46 20.22  1  0    3    1

For the second case,

R> mtcars[rownames(mtcars) != "Valiant",]

will do it.

See also ?subset.

HTH,
Jorge.-


On Fri, Feb 17, 2012 at 3:02 AM, Ajay Askoolum <> wrote:

> data(mtcars)
>
> mtcars[rownames(mtcars)!="Valiant",] # fails
>
> mtcars[list(rownames(mtcars))!="Valiant",] # runs but I am not getting the
> expected result
>
> With the latter statement, I expected all rows except the one where the
> name is "Valiant".
>
> I must have got something simple wrong; what is it?
>
> Thanks.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

