[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) (131.174.146.31)
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
v
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
v
V412 a
V411 b
> x[ "V41", ]
[1] <NA>
Levels: a b
sessionInfo() output:
> sessionInfo()
R version 2.5.0 (2007-04-23)
i686-pc-linux-gnu
locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7] "base"
other attached packages:
lattice
"0.15-4"
More information about the R-devel
mailing list