<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Michael,</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">Excellent example. Perfectly reproducible on 1.9.2 and 1.9.3. And it works fine on 1.8.10. The answer should've only 3 rows. </div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">It'd be even more nice of you if you could file it as a bug report.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">PS: On another note.. you maybe also interested in `CS[SP, roll=TRUE, rollends=TRUE]`</div> <div id="bloop_sign_1403264352854212096" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">Arun</div></div> <div style="color:black"><br>From: <span style="color:black">Michael Smith</span> <a href="mailto:my.r.help@gmail.com">my.r.help@gmail.com</a><br>Reply: <span style="color:black">Michael Smith</span> <a href="mailto:my.r.help@gmail.com">my.r.help@gmail.com</a><br>Date: <span style="color:black">June 20, 2014 at 1:30:09 PM</span><br>To: <span style="color:black">Arunkumar Srinivasan</span> <a href="mailto:aragorn168b@gmail.com">aragorn168b@gmail.com</a><br>Cc: <span style="color:black">datatable-help@lists.r-forge.r-project.org</span> <a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>Subject: <span style="color:black"> Re: [datatable-help] Bug when Merging with nomatch=0 and roll=T? <br></span></div><br> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>OK, no problem, here's the code. If there are any problems pasting it
<br>into R let me know (I used parts of dput, so maybe the email line
<br>endings are messed up). If you want I can also file a bug report on
<br>github, just let me know.
<br>
<br>CS <-
<br> data.table(
<br> structure(list(LPERMCO = c(7L, 33L), datadate = structure(c(15912,
<br>15912), class = "Date"), me = c(626550.35284, 7766.385)), .Names =
<br>c("LPERMCO",
<br>"datadate", "me"), class = "data.frame", row.names = c(NA, -2L
<br>)),
<br> key = "LPERMCO,datadate")
<br>SP <-
<br> data.table(
<br> structure(list(PERMCO = c(7L, 7L, 33L, 33L, 33L, 33L), date =
<br>structure(c(15884,
<br>15917, 15884, 15884, 15917, 15917), class = "Date"), RET = c(-0.118303,
<br>0.141225, -0.03137, -0.02533, 0.045967, 0.043694)), .Names = c("PERMCO",
<br>"date", "RET"), class = "data.frame", row.names = c(NA, -6L)),
<br> key = "PERMCO,date")
<br>sapply(CS[SP, nomatch = 0, roll = T], length)
<br>
<br>
<br>The relevant output looks like this, both in 1.9.2 and in dev-1.9.3, and
<br>for sapply, the "me" column should be 5 but it's 3:
<br>
<br>> CS
<br> LPERMCO datadate me
<br>1: 7 2013-07-26 626550.353
<br>2: 33 2013-07-26 7766.385
<br>> SP
<br> PERMCO date RET
<br>1: 7 2013-06-28 -0.118303
<br>2: 7 2013-07-31 0.141225
<br>3: 33 2013-06-28 -0.031370
<br>4: 33 2013-06-28 -0.025330
<br>5: 33 2013-07-31 0.045967
<br>6: 33 2013-07-31 0.043694
<br>> CS[SP, nomatch = 0, roll = T]
<br> LPERMCO datadate me RET
<br>1: 7 2013-07-31 626550.353 0.141225
<br>2: 33 2013-06-28 7766.385 -0.031370
<br>3: 33 2013-06-28 7766.385 -0.025330
<br>4: 33 2013-07-31 626550.353 0.045967
<br>5: 33 2013-07-31 7766.385 0.043694
<br>Warning message:
<br>In cbind(LPERMCO = c(" 7", "33", "33", "33", "33"), datadate =
<br>c("2013-07-31", :
<br> number of rows of result is not a multiple of vector length (arg 3)
<br>> sapply(CS[SP, nomatch = 0, roll = T], length)
<br> LPERMCO datadate me RET
<br> 5 5 3 5
<br>
<br>
<br>Thanks,
<br>M
<br>
<br>
<br>
<br>
<br>
<br>On 06/20/2014 05:17 PM, Arunkumar Srinivasan wrote:
<br>>> For a given data.table, is there any condition … Ergo, it's a bug,
<br>>> right?
<br>>
<br>> Yes.
<br>>
<br>>> I'll be glad
<br>>> to try to boil this down to something that's reproducible.
<br>>
<br>> That'd be great.
<br>>
<br>>
<br>> Arun
<br>>
<br>> From: Michael Smith my.r.help@gmail.com <mailto:my.r.help@gmail.com>
<br>> Reply: Michael Smith my.r.help@gmail.com <mailto:my.r.help@gmail.com>
<br>> Date: June 20, 2014 at 5:37:24 AM
<br>> To: datatable-help@lists.r-forge.r-project.org
<br>> datatable-help@lists.r-forge.r-project.org
<br>> <mailto:datatable-help@lists.r-forge.r-project.org>
<br>> Subject: Re: [datatable-help] Bug when Merging with nomatch=0 and roll=T?
<br>>
<br>>> So let me rephrase my question (haven't received an answer so far):
<br>>>
<br>>> For a given data.table, is there any condition under which the lengths
<br>>> of the vectors in each column may differ? Based on my understanding,
<br>>> each data.table is also a data.frame, and with a data frame this should
<br>>> not be possible. For example, it's not possible to have a data.frame
<br>>> where the first column is a vector of length eight, and the second
<br>>> column is a vector of length nine. Ergo, it's a bug, right?
<br>>>
<br>>> If my understanding is correct, please do let me know and I'll be glad
<br>>> to try to boil this down to something that's reproducible.
<br>>>
<br>>> Thanks,
<br>>> M
<br>>>
<br>>> On 06/19/2014 11:59 AM, Michael Smith wrote:
<br>>> > By the way, I know it's not reproducible with the code below. Before
<br>>> > going into further detail, I first wanted to ask whether this looks like
<br>>> > a bug, or whether I've overlooked something obvious and this is expected
<br>>> > behavior.
<br>>> >
<br>>> > Thanks,
<br>>> > M
<br>>> >
<br>>> > On 06/19/2014 11:51 AM, Michael Smith wrote:
<br>>> >> I got the following result on my keyed data tables `CS` and `SP`, which
<br>>> >> seems like a bug (in 1.9.2 and 1.9.3 dev version) to me, since all
<br>>> >> columns should have the _same_ length:
<br>>> >>
<br>>> >>> ## Works as expected:
<br>>> >>> all((l <- sapply(CS[SP, roll = TRUE], length)) == l[1])
<br>>> >> [1] TRUE
<br>>> >>> ## Works as expected:
<br>>> >>> all((l <- sapply(CS[SP, nomatch = 0], length)) == l[1])
<br>>> >> [1] TRUE
<br>>> >>> ## Here's the potential _bug_, when combining both:
<br>>> >>> all((l <- sapply(CS[SP, nomatch = 0, roll = TRUE], length)) == l[1])
<br>>> >> [1] FALSE
<br>>> >>
<br>>> >>
<br>>> >> Thanks,
<br>>> >>
<br>>> >> M
<br>>> >>
<br>>> _______________________________________________
<br>>> datatable-help mailing list
<br>>> datatable-help@lists.r-forge.r-project.org
<br>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
<br>>>
<br></div></div></span></blockquote></body></html>