[Rd] hash access to data.frame uses prefix? (PR#10474)

pkensche at cmbi.ru.nl pkensche at cmbi.ru.nl
Wed Nov 28 09:25:31 CET 2007

Full_Name: Philip Kensche
Version: R version 2.5.0 (2007-04-23)
OS: Linux
Submission from: (NULL) (

I want to access a row of a data.frame() by using the row names as hash keys.
This works fine for most keys.

Now consider the following data.frame().

> x <- data.frame(v=c(V40="a", V411="b"))

> x
V40  a
V411 b

If I query for "V41", which does not exist in the data.frame() the call does not
return NA as I would expect but the row "V411".

> x[ "V41", ]
[1] b
Levels: a b

If there the prefix is not unique the query does not return a results, i.e.

> x <- data.frame(v=c(V412="a", V411="b"))

> x
V412 a
V411 b

> x[ "V41", ]
[1] <NA>
Levels: a b

sessionInfo() output:
> sessionInfo()
R version 2.5.0 (2007-04-23)


attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
[7] "base"

other attached packages:

More information about the R-devel mailing list