On May 19, 2010, at 12:14 PM, Hilmar Berger wrote:
Hi all,
This occurred in R-2.11.0 (WinXP).
The R-help page of .[ says that:
"Character indices can in some circumstances be partially matched (see
pmatch) to the names or dimnames of the object being subsetted (but
never
for subassignment). Unlike S (Becker et al p. 358)), R has never used
partial matching when extracting by [, and as from R 2.7.0 partial
matching
is not by default used by [[ (see argument exact)."
My understanding is therefore that .[ should never try partial
matching.
That was for [.matrix or similar (as noted at top of the page). You
created a different class of variable.
?"[.data.frame
"Both [ and [[ extraction methods partially match row names. By
default neither partially match column names, but [[ will unless
exact=TRUE. If you want to do exact matching on row names use match as
in the examples."
--
David.
However:
df = data.frame(a=c(1,2,3,9), b=c(4,5,6,10))
rownames(df) = c("ef","gg","hh","fe")
df
a b
ef 1 4
gg 2 5
hh 3 6
fe 9 10
df["e",]
a b
ef 1 4
rownames(df) = c("ef","gg","hh","efg")
df["e",]
a b
NA NA NA
So, it looks like partial matching is done using
pmatch("e",rownames(df))
for "[". If this is true, the help page is not correct.
Thanks !
Regards,
Hilmar
---
Hilmar Berger
Integromics S.L. / CNB-CSIC
Madrid, Spain
[[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.
David Winsemius, MD
West Hartford, CT
______________________________________________
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.