Is there a way to select a subset of a dataframe consisting of all
those rows with rownames *except* from a subset of rownames to be
excluded? Example:
> a <- data.frame(x=1:10,y=10:1)
> a <- a[order(a$y),] # to make rownames differ visually
> a[8,]
x y
3 3 8
> a["8",]
x y
8 8 3
> a[-8,]
x y
10 10 1
9 9 2
8 8 3
7 7 4
6 6 5
5 5 6
4 4 7
2 2 9
1 1 10
> a[-"8",]
Error in -"8" : invalid argument to unary operator
-- is there a similar exclusion operator or simple way? So far the
best I can do is
> a[setdiff(rownames(a),"8"),]
x y
10 10 1
9 9 2
7 7 4
6 6 5
5 5 6
4 4 7
3 3 8
2 2 9
1 1 10
Cheers,
Alexy
______________________________________________
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.