Bug 16705 - inconsistent error reporting in reshape()
Summary: inconsistent error reporting in reshape()
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R-devel (trunk)
Hardware: Other Other
: P5 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2016-02-09 19:56 UTC by Bill Dunlap
Modified: 2016-02-09 19:56 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bill Dunlap 2016-02-09 19:56:05 UTC
If you supply one nonexistent name for the 'v.names' argument to reshape you get a result (probably not the one you want, but equivalent to v.names=character()).  If you supply more than one nonexistant name it throws an error.  Should it throw an error in either case?  Or should it ignore v.names entries not in the data.frame 'data' in both cases?

DF <- data.frame(Time=rep(1:4,3), A=rep(11:13,each=4),B=rep(21:23,each=4),C=rep(21:23,each=4),D=rep(31:33,each=4))
reshape(DF, timevar="Time", idvar="A", direction="wide", v.names=c("noSuchName"))
#   A  B  C  D
#1 11 21 21 31
#5 12 22 22 32
#9 13 23 23 33
reshape(DF, timevar="Time", idvar="A", direction="wide", v.names=c("noSuchName","anotherBadName"))
#Error in `[.data.frame`(thistime, match(rval[, idvar], thistime[, idvar]),  :
#  undefined columns selected


> sessionInfo()
R Under development (unstable) (2016-02-02 r70074)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

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