Skip to content

Commit

Permalink
fix to [.data.frame for duplicate column names
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@41492 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
ripley committed May 8, 2007
1 parent 875a21d commit 4566410
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ BUG FIXES

o rbind() failed if the only data frame had 0 rows. (PR#9657)

o <a data.frame>[i, j] could sometimes select the wrong column
when j is numeric if there are duplicate column names.



CHANGES IN R VERSION 2.5.0
Expand Down
4 changes: 3 additions & 1 deletion src/library/base/R/dataframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,9 @@ data.frame <-
x <- x[j]
cols <- names(x) # also needed for 'drop'
if(any(is.na(cols))) stop("undefined columns selected")
sxx <- match(cols, names(xx))
## sxx <- match(cols, names(xx)) fails with duplicate names
nxx <- structure(seq_along(xx), names=names(xx))
sxx <- match(nxx[j], seq_along(xx))
} else sxx <- seq_along(x)

rows <- NULL # placeholder: only create row names when needed
Expand Down

0 comments on commit 4566410

Please sign in to comment.