Dear UseRs, I just learnt that the number of columns of a data frame is not always what I thought it to be, and I wonder where I should have learnt about this. Consider the following example:
dat <- data.frame(X1=1:10, X2=LETTERS[1:10]) ncol(dat) ## evaluates to 2 (of course) dat$X1poly <- poly(dat$X1,3) dat ## five columns displayed ncol(dat) ## evaluates to 3 colnames(dat) ## three names (third is X1poly) colnames(dat)[3] <- "newname" dat ## all three previous X1poly columns renamed This appears intentional, as it treats the column names reasonably. Where is it documented ? Are there any other scenarios for which the number of columns displayed when printing a data frame does not coincide with ncol ? Regards, Ulrike -- View this message in context: http://www.nabble.com/poly-objects-as-data-frame-columns-tp24538067p24538067.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.