jens.oehlschlaegel-akiyoshi@mdfactory.de
2000-Jan-26 16:24 UTC
data.frame[1,1]<- differs from data.frame[[1]][1]<- (PR#403)
I observed the following difference:> ddd <- data.frame(a=1:3, b=1:3)# assignment of 'X' silently ignored> ddd[1,1] <- 'X' > is.factor(ddd[[1]])[1] FALSE> ddda b 1 1 1 2 2 2 3 3 3 # assignment of 'X' not ignored> ddd[[1]][1] <- 'X' > is.factor(ddd[[1]])[1] TRUE> ddda b 1 X 1 2 2 2 3 3 3 Regards> version_ platform Windows arch x86 os Win32 system x86, Win32 status major 0 minor 90.1 year 1999 month December day 15 language R -- Dr. Jens Oehlschlägel-Akiyoshi MD FACTORY GmbH Bayerstrasse 21 80335 München Tel.: 089 545 28-27 Fax.: 089 545 28-10 http://www.mdfactory.de -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Prof Brian Ripley
2000-Jan-26 17:26 UTC
data.frame[1,1]<- differs from data.frame[[1]][1]<- (PR#403)
> From: jens.oehlschlaegel-akiyoshi@mdfactory.de > Date: Wed, 26 Jan 2000 17:24:05 +0100 (MET) > > > I observed the following difference: > > > ddd <- data.frame(a=1:3, b=1:3) > > # assignment of 'X' silently ignored > > ddd[1,1] <- 'X' > > is.factor(ddd[[1]]) > [1] FALSE > > ddd > a b > 1 1 1 > 2 2 2 > 3 3 3actually it assigns as.numeric(factor("X")), which is 1.> # assignment of 'X' not ignored > > ddd[[1]][1] <- 'X' > > is.factor(ddd[[1]]) > [1] TRUE > > ddd > a b > 1 X 1 > 2 2 2 > 3 3 3 >Here is my solution: line 488 in dataframe.R, in "[<-.data.frame" ## careful, as.data.frame turns things into factors. ## value <- as.data.frame(value) if(!is.list(value) && (missing(j) || !missing(i))) { # [i, ] or [i,j] value <- matrix(value, n, p) dimv <- c(n, p) value <- split(value, col(value)) } else { value <- as.data.frame(value) dimv <- dim(value) } It covers the same cases as the prototype, but is a kludge, of course. -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._