-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Submitted by: Christophe Dervieux; Assigned to: Arun ; R-Forge link
Hi,
I have updated data.table package to 1.9.2 recently from 1.8.10 and I found errors on my previous code.
See reproductible example below:
On 1.8.10 :
DT <- data.table(X = factor(2006:2012), Y = rep(1:7, 2))
DT[, Z := paste(X, .N, sep = " - "), by = list(X)][]
X Y Z
1: 2006 1 2006 - 2
2: 2007 2 2007 - 2
3: 2008 3 2008 - 2
4: 2009 4 2009 - 2
5: 2010 5 2010 - 2
6: 2011 6 2011 - 2
7: 2012 7 2012 - 2
8: 2006 1 2006 - 2
9: 2007 2 2007 - 2
10: 2008 3 2008 - 2
11: 2009 4 2009 - 2
12: 2010 5 2010 - 2
13: 2011 6 2011 - 2
14: 2012 7 2012 - 2
In column Z, I get the level of the factor column X
pasted with count '.N' as expected
However, in the 1.9.2, with same code :
DT<-data.table(X=factor(2006:2012),Y=rep(1:7,2))
DT[,Z:=paste(X,.N,sep=" - "),by=list(X)][]
X Y Z
1: 2006 1 1 - 2
2: 2007 2 2 - 2
3: 2008 3 3 - 2
4: 2009 4 4 - 2
5: 2010 5 5 - 2
6: 2011 6 6 - 2
7: 2012 7 7 - 2
8: 2006 1 1 - 2
9: 2007 2 2 - 2
10: 2008 3 3 - 2
11: 2009 4 4 - 2
12: 2010 5 5 - 2
13: 2011 6 6 - 2
14: 2012 7 7 - 2
as results, I do not get levels of factor column X but the numeric values associated with the level.
is this working normally? Why has it changed? Is that a bug?
I use this kind of procedure to make labels for ggplot
. All my previous code is not working anymore. It's kind of annoying.
Thanks
Christophe