timh at insightful.com
2008-Jan-14 18:40 UTC
[Rd] illegal data frame produced by [<-.data.frame (PR#10574)
> x <- data.frame(a=1:3,b=2:4) > x[,3] <- xWarning message: In `[<-.data.frame`(`*tmp*`, , 3, value = list(a = 1:3, b = 2:4)) : provided 2 variables to replace 1 variables> xa b a.1 b.1 1 1 2 1 NULL 2 2 3 2 <NA> 3 3 4 3 <NA> Warning message: In format.data.frame(x, digits = digits, na.encode = FALSE) : corrupt data frame: columns will be truncated or padded with NAs In S-PLUS, the first warning is given, then a legal data frame is produced, using only the first column of value. The following change to R's "[<-.data.frame" gives that behavior. Change: else if (ncolv > p) warning(gettextf("provided %d variables to replace %d variables", ncolv, p), domain = NA) to: else if (ncolv > p) { warning(gettextf("provided %d variables to replace %d variables", ncolv, p), domain = NA) new.cols <- new.cols[seq_len(p)] } --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = major = 2 minor = 6.1 year = 2007 month = 11 day = 26 svn rev = 43537 language = R version.string = R version 2.6.1 (2007-11-26) Windows XP (build 2600) Service Pack 2.0 Locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 Search Path: .GlobalEnv, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, package:methods, Autoloads, package:base
Apparently Analagous Threads
- bad variable names when printing a data frame containing a matrix (PR#10730)
- is(x, "parent") returns FALSE when class(x) is c("child", "parent") (PR#10549)
- help("R_LIBS") brings up the wrong help file (PR#10475)
- rJava not loading on Windows
- Open .ssc .S ... files in R (PR#8690)