<div>Matt</div><div><br></div>I made a much simpler example that only involves the first data.table<div><br></div><div>Also, although I had a POSIX date before, this example just has the text for the date.<br><div><br></div>
<div>It appears that the longer text columns are causing a problem. </div><div><br></div><div>I'm saving as an RData file, and I also try using Rds at the end, but with no difference.</div><div><br></div><div>Now I'm more convinced that the problem is in data.table, but I'm not ruling out user error. </div>
<div><br></div><div><div><font face="courier new, monospace">> ## I was able to reproduce a simpler example </font></div><div><font face="courier new, monospace">> ## without the second data.table</font></div><div><font face="courier new, monospace">> </font></div>
<div><font face="courier new, monospace">> ## Here is the data (with generic column names)</font></div><div><font face="courier new, monospace">> str(datMod)</font></div><div><font face="courier new, monospace">Classes ‘data.table’ and 'data.frame':<span class="Apple-tab-span" style="white-space:pre"> </span>3103314 obs. of 41 variables:</font></div>
<div><font face="courier new, monospace"> $ char1 : chr "<a href="http://conradhotels3.hilton.com">http://conradhotels3.hilton.com</a>" "<a href="http://conradhotels3.hilton.com">http://conradhotels3.hilton.com</a>" "<a href="http://conradhotels3.hilton.com">http://conradhotels3.hilton.com</a>" "<a href="http://conradhotels3.hilton.com">http://conradhotels3.hilton.com</a>" ...</font></div>
<div><font face="courier new, monospace"> $ char2 : chr "/en/index.html" "/en/index.html" "/en/index.html" "/en/index.html" ...</font></div><div><font face="courier new, monospace"> $ char3 : chr "" "" "" "" ...</font></div>
<div><font face="courier new, monospace"> $ int1 : int 44903 44903 44903 44903 44903 44903 44903 44903 44903 44903 ...</font></div><div><font face="courier new, monospace"> $ int2 : int 411 411 254 254 336 336 118 118 386 386 ...</font></div>
<div><font face="courier new, monospace"> $ char4 : chr "2012-05-09 20:17:40.587" "2012-05-09 21:17:54.427" "2012-05-09 20:10:49.560" "2012-05-09 21:11:05.107" ...</font></div><div>
<font face="courier new, monospace"> $ int3 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div><div><font face="courier new, monospace"> $ int4 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div><div><font face="courier new, monospace"> $ int5 : int 69 69 69 69 69 69 69 68 68 68 ...</font></div>
<div><font face="courier new, monospace"> $ int6 : int 68 68 68 68 68 68 68 67 67 67 ...</font></div><div><font face="courier new, monospace"> $ int7 : int 35 35 37 35 35 35 33 38 38 40 ...</font></div><div><font face="courier new, monospace"> $ int8 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div>
<div><font face="courier new, monospace"> $ int9 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div><div><font face="courier new, monospace"> $ int10 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div><div><font face="courier new, monospace"> $ int11 : int 1 1 1 1 1 1 1 1 1 1 ...</font></div>
<div><font face="courier new, monospace"> $ int12 : int 334830 334847 335102 334838 334836 342687 334521 318626 318578 326800 ...</font></div><div><font face="courier new, monospace"> $ int13 : int 36 36 37 36 36 36 35 38 37 39 ...</font></div>
<div><font face="courier new, monospace"> $ int14 : int 44 44 49 47 45 45 45 46 45 48 ...</font></div><div><font face="courier new, monospace"> $ char5 : chr "" "" "" "" ...</font></div>
<div><font face="courier new, monospace"> $ int15 : int NA NA NA NA NA NA NA NA NA NA ...</font></div><div><font face="courier new, monospace"> $ int16 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div><div><font face="courier new, monospace"> $ int17 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div>
<div><font face="courier new, monospace"> $ int18 : int 2 2 2 2 2 2 2 2 2 2 ...</font></div><div><font face="courier new, monospace"> $ int19 : int 1381 1152 424 3728 1772 921 385 725 401 314 ...</font></div><div><font face="courier new, monospace"> $ int20 : int 36 36 37 36 36 36 35 38 37 39 ...</font></div>
<div><font face="courier new, monospace"> $ int21 : int 2199 2201 1492 1448 2559 2529 1084 1432 1876 1984 ...</font></div><div><font face="courier new, monospace"> $ int22 : int 44 44 49 47 45 45 45 46 45 48 ...</font></div>
<div><font face="courier new, monospace"> $ int23 : int 2203 2188 1199 1162 2324 2346 821 897 1386 1189 ...</font></div><div><font face="courier new, monospace"> $ int24 : int 13 13 14 13 13 13 12 13 13 14 ...</font></div>
<div><font face="courier new, monospace"> $ int25 : int 5166 5761 3755 3794 5614 7779 2830 3971 4637 5871 ...</font></div><div><font face="courier new, monospace"> $ int26 : int 103 103 105 103 103 103 101 105 105 107 ...</font></div>
<div><font face="courier new, monospace"> $ int27 : int 70 183 159 197 217 165 153 232 92 102 ...</font></div><div><font face="courier new, monospace"> $ int28 : int 103 103 105 103 103 103 101 105 105 107 ...</font></div>
<div><font face="courier new, monospace"> $ int29 : int 0 0 0 0 0 0 0 0 0 0 ...</font></div><div><font face="courier new, monospace"> $ int30 : int 161 146 200 158 150 160 190 161 163 169 ...</font></div><div><font face="courier new, monospace"> $ char6 : chr "Limelight" "Limelight" "Fusepoint/Savvis" "Fusepoint/Savvis" ...</font></div>
<div><font face="courier new, monospace"> $ char7 : chr "Paris" "Paris" "Toronto" "Toronto" ...</font></div><div><font face="courier new, monospace"> $ char8 : chr "-1" "-1" "-1" "-1" ...</font></div>
<div><font face="courier new, monospace"> $ char9 : chr "FRANCE" "FRANCE" "CANADA" "CANADA" ...</font></div><div><font face="courier new, monospace"> $ char10: chr "FR" "FR" "CA" "CA" ...</font></div>
<div><font face="courier new, monospace"> $ char11: chr "FRANCE" "FRANCE" "CANADA" "CANADA" ...</font></div><div><font face="courier new, monospace"> - attr(*, ".internal.selfref")=<externalptr> </font></div>
<div><font face="courier new, monospace">> </font></div><div><font face="courier new, monospace">> ## Here is the size when you save that file</font></div><div><font face="courier new, monospace">> save(datMod, file='test0.Rdata')</font></div>
<div><font face="courier new, monospace">> originalfilesize = <a href="http://file.info">file.info</a>('test0.RData')$size</font></div><div><font face="courier new, monospace">> formatC(originalfilesize, big.mark=',', format='f', digits=0) </font></div>
<div><font face="courier new, monospace">[1] "71,085,933"</font></div><div><font face="courier new, monospace">> </font></div><div><font face="courier new, monospace">> ## Here is the size after you set the key</font></div>
<div><font face="courier new, monospace">> setkey(datMod, char4)</font></div><div><font face="courier new, monospace">> save(datMod, file='test1.Rdata')</font></div><div><font face="courier new, monospace">> newfilesize = <a href="http://file.info">file.info</a>('test1.RData')$size</font></div>
<div><font face="courier new, monospace">> formatC(newfilesize, big.mark=',', format='f', digits=0) </font></div><div><font face="courier new, monospace">[1] "195,406,633"</font></div><div><font face="courier new, monospace">> </font></div>
<div><font face="courier new, monospace">> ## Some of the columns have a large size</font></div><div><font face="courier new, monospace">> datMod[,range(nchar(char2))]</font></div><div><font face="courier new, monospace">[1] 1 1606</font></div>
<div><font face="courier new, monospace">> datMod[,range(nchar(char3))]</font></div><div><font face="courier new, monospace">[1] 0 2048</font></div><div><font face="courier new, monospace">> </font></div><div><font face="courier new, monospace">> ## If I remove the long columns it helps reduce the file size</font></div>
<div><font face="courier new, monospace">> datMod$char2 = NULL</font></div><div><font face="courier new, monospace">> datMod$char3 = NULL</font></div><div><font face="courier new, monospace">> </font></div><div><font face="courier new, monospace">> save(datMod, file='test2.Rdata')</font></div>
<div><font face="courier new, monospace">> secondfilesize = <a href="http://file.info">file.info</a>('test2.RData')$size</font></div><div><font face="courier new, monospace">> formatC(secondfilesize, big.mark=',', format='f', digits=0) </font></div>
<div><font face="courier new, monospace">[1] "121,237,355"</font></div><div><div><font face="courier new, monospace">> </font></div></div><div><div><font face="courier new, monospace">> ## Using RDS doesn't matter</font></div>
</div><div><font face="courier new, monospace">> saveRDS(datMod, file='test2.Rds')</font></div><div><font face="courier new, monospace">> secondfilesizeRDS = <a href="http://file.info">file.info</a>('test2.Rds')$size</font></div>
<div><font face="courier new, monospace">> formatC(secondfilesizeRDS, big.mark=',', format='f', digits=0) </font></div><div><font face="courier new, monospace">[1] "121,237,288"</font></div></div>
<div><br></div></div>