Gary Collins
2006-May-10 13:35 UTC
[R] problem rbind after lapply (difference between 2.2.1 and 2.3.0)
Any help on the following would be appreciated...> R.version_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 2.1 year 2005 month 12 day 20 svn rev 36812> language R > set.seed(2) > x=matrix(ncol=4, nrow=10) > for(i in 1:4) x[,i]=rnorm(10) > x=as.data.frame(x) > x$V1=c(rep(0,5), rep(1,5)) > xV1 V2 V3 V4 1 0 0.41765075 2.090819205 0.7389386 2 0 0.98175278 -1.199925820 0.3189604 3 0 -0.39269536 1.589638200 1.0761644 4 0 -1.03966898 1.954651642 -0.2841577 5 0 1.78222896 0.004937777 -0.7766753 6 1 -2.31106908 -2.451706388 -0.5956605 7 1 0.87860458 0.477237303 -1.7259798 8 1 0.03580672 -0.596558169 -0.9025845 9 1 1.01282869 0.792203270 -0.5590619 10 1 0.43226515 0.289636710 -0.2465126> do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2))))min max 0 -1.039669 1.782229 1 -2.311069 1.012829 yet with the same call on version 2.3.0, I get the following error.> do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2))))Error in data.frame(min = c("-1.039669", "-2.311069"), max = c("1.782229", : row names contain missing values Any clues on what has changed between the two versions? and a fix to get around this? The actual function (min, max) within the lapply is just an example for illustration only, the issue is the "rbinding" of results from an lapply call. I've had a look at the changes document packaged with 2.3.0 and found nothing...so wondering whether it's a bug or not? Thanks in advance. Gary
Gabor Grothendieck
2006-May-10 13:42 UTC
[R] problem rbind after lapply (difference between 2.2.1 and 2.3.0)
Update your R: https://www.stat.math.ethz.ch/pipermail/r-devel/2006-May/037542.html On 5/10/06, Gary Collins <collins.gs at gmail.com> wrote:> Any help on the following would be appreciated... > > > R.version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 2.1 > year 2005 > month 12 > day 20 > svn rev 36812 > > language R > > set.seed(2) > > x=matrix(ncol=4, nrow=10) > > for(i in 1:4) x[,i]=rnorm(10) > > x=as.data.frame(x) > > x$V1=c(rep(0,5), rep(1,5)) > > x > V1 V2 V3 V4 > 1 0 0.41765075 2.090819205 0.7389386 > 2 0 0.98175278 -1.199925820 0.3189604 > 3 0 -0.39269536 1.589638200 1.0761644 > 4 0 -1.03966898 1.954651642 -0.2841577 > 5 0 1.78222896 0.004937777 -0.7766753 > 6 1 -2.31106908 -2.451706388 -0.5956605 > 7 1 0.87860458 0.477237303 -1.7259798 > 8 1 0.03580672 -0.596558169 -0.9025845 > 9 1 1.01282869 0.792203270 -0.5590619 > 10 1 0.43226515 0.289636710 -0.2465126 > > > do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2)))) > min max > 0 -1.039669 1.782229 > 1 -2.311069 1.012829 > > yet with the same call on version 2.3.0, I get the following error. > > > do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2)))) > Error in data.frame(min = c("-1.039669", "-2.311069"), max = c("1.782229", : > row names contain missing values > > Any clues on what has changed between the two versions? and a fix to > get around this? The actual function (min, max) within the lapply is > just an example for illustration only, the issue is the "rbinding" of > results from an lapply call. I've had a look at the changes document > packaged with 2.3.0 and found nothing...so wondering whether it's a > bug or not? > > Thanks in advance. > > Gary > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Prof Brian Ripley
2006-May-10 15:16 UTC
[R] problem rbind after lapply (difference between 2.2.1 and 2.3.0)
This is already fixed in R-patched: o rbind()ing dataframes with a single row could lead to a corrupt data frame (a problem with the fix to PR#8506). On Wed, 10 May 2006, Gary Collins wrote:> Any help on the following would be appreciated... > >> R.version > _ > platform i386-pc-mingw32 > arch i386 > os mingw32 > system i386, mingw32 > status > major 2 > minor 2.1 > year 2005 > month 12 > day 20 > svn rev 36812 >> language R >> set.seed(2) >> x=matrix(ncol=4, nrow=10) >> for(i in 1:4) x[,i]=rnorm(10) >> x=as.data.frame(x) >> x$V1=c(rep(0,5), rep(1,5)) >> x > V1 V2 V3 V4 > 1 0 0.41765075 2.090819205 0.7389386 > 2 0 0.98175278 -1.199925820 0.3189604 > 3 0 -0.39269536 1.589638200 1.0761644 > 4 0 -1.03966898 1.954651642 -0.2841577 > 5 0 1.78222896 0.004937777 -0.7766753 > 6 1 -2.31106908 -2.451706388 -0.5956605 > 7 1 0.87860458 0.477237303 -1.7259798 > 8 1 0.03580672 -0.596558169 -0.9025845 > 9 1 1.01282869 0.792203270 -0.5590619 > 10 1 0.43226515 0.289636710 -0.2465126 > >> do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2)))) > min max > 0 -1.039669 1.782229 > 1 -2.311069 1.012829 > > yet with the same call on version 2.3.0, I get the following error. > >> do.call("rbind", lapply(split(x, x$V1), function(x) data.frame(min=min(x$V2), max=max(x$V2)))) > Error in data.frame(min = c("-1.039669", "-2.311069"), max = c("1.782229", : > row names contain missing values > > Any clues on what has changed between the two versions? and a fix to > get around this? The actual function (min, max) within the lapply is > just an example for illustration only, the issue is the "rbinding" of > results from an lapply call. I've had a look at the changes document > packaged with 2.3.0 and found nothing...so wondering whether it's a > bug or not? > > Thanks in advance. > > Gary > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Brian D. Ripley, ripley at 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595