Have you gone through any R tutorials?
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
Try something like the following.
ix <- which(c("601", "604") %in% rownames(data))
clean <- data[-ix, ]
Hope this helps,
Rui Barradas
Citando Pauline Laïlle <pauline...@gmail.com>:
ix <- which(rownames(data) %in% c("601", "604"))
clean <- data[-ix, ]
Rui Barradas
Citando ruipba...@sapo.pt:
The error message means exactly what it says. The operator '-' is
unary and cannot be followed by a non-numeric atomic object (a vector).
Try for instance
x <- list(a=1:10, b=rnorm(5))
-x
Rui Barradas
Citando Pauline Laïlle <pauline...@gmail.com>:
> Works like a charm, thanks! Still don't know what that error message
> means though. Any idea?
The OP needs to carefully read
?"["
and/or spend some time with a suitable R tutorial to learn proper
syntax for subscripting. Asking foolish questions in lieu of doing her
homework seems wrongheaded to me. Others may disagree, of course.
Cheers,
Bert
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
E.g. subset() evaluates each argument in a different way:
> subset(data.frame(ColA=1:3,ColB=-(11:13)), -ColB>11, -ColA)
ColB
2 -12
3 -13
Bill Dunlap
TIBCO Software
wdunlap tibco.com
2016-09-20 20:13 GMT+02:00 <ruipba...@sapo.pt>:
>> <javascript:_e(%7B%7D,'cvml','pauline...@gmail.com');>>:
>> >
>> >> Works like a charm, thanks! Still don't know what that error message
>> >> means though. Any idea?
>> >>
>> >> 2016-09-20 20:13 GMT+02:00 <ruipba...@sapo.pt
>> <javascript:_e(%7B%7D,'cvml','ruipba...@sapo.pt');>>:
>> >>> Sorry, I've made a stupid mistake.
>> >>> It's obviously the other way around.
>> >>>
>> >>> ix <- which(rownames(data) %in% c("601", "604"))
>> >>> clean <- data[-ix, ]
>> >>>
>> >>> Rui Barradas
>> >>>
>> >>> Citando ruipba...@sapo.pt
>> <javascript:_e(%7B%7D,'cvml','ruipba...@sapo.pt');>:
>> >>>> Hello,
>> >>>>
>> >>>> Try something like the following.
>> >>>>
>> >>>> ix <- which(c("601", "604") %in% rownames(data))
>> >>>> clean <- data[-ix, ]
>> >>>>
>> >>>> Hope this helps,
>> >>>>
>> >>>> Rui Barradas
>> >>>>
>> >>>> Citando Pauline Laïlle <pauline...@gmail.com
>> <javascript:_e(%7B%7D,'cvml','pauline...@gmail.com');>>:
>> <javascript:_e(%7B%7D,'cvml','R-h...@r-project.org');> mailing list --
>> To UNSUBSCRIBE and more, see
>> >>>>> 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.
>> >>>>
>> >>>> ______________________________________________
>> >>>> R-h...@r-project.org
>> <javascript:_e(%7B%7D,'cvml','R-h...@r-project.org');> mailing list --
>> To UNSUBSCRIBE and more, see
>> >>>> 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]]
>> >
>> > ______________________________________________
>> > R-h...@r-project.org
>> <javascript:_e(%7B%7D,'cvml','R-h...@r-project.org');> mailing list --
>> To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>>
>> ______________________________________________
>> R-h...@r-project.org
>> <javascript:_e(%7B%7D,'cvml','R-h...@r-project.org');> mailing list --
>> To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posti
>> ng-guide.html
data["601",] doesn't generate an error because you can also refer to a
row by its name, as an alternative to refering to it by row number.
It's the same with vectors, just consider the following case.
(x <- c("601"=1, b=2))
x[1]
x["601"] # the same
But when you want to remove it you must negate an index number so
x[-"601"] is wrong for reasons already explained.
Rui Barradas
Citando Pauline Laïlle <pauline...@gmail.com>: