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

From: <pkensche_at_cmbi.ru.nl>
Date: Wed, 28 Nov 2007 09:25:31 +0100 (CET)

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:

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 28 Nov 2007 - 09:02:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 28 Nov 2007 - 15:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.