« first day (59 days earlier)      last day (3240 days later) » 

5:11 PM
@Frank Consider to post that as an answer
 
5:29 PM
@akrun you mean the edit i made?
you can go ahead and undelete it
 
@Frank I just undeleted
 
ok cool
 
but you made a lot of edits, I thought you could have posted that as a separate solution
 
i'm fine with doing it this way (which is why i edited). i'd never seen within.list and so wouldn't have come up with that myself, anyway
useful function
 
@Frank The key was to use two inverse.rle. I was trying to do this in a single inverse.rle and had all sorts of problem.
 
5:46 PM
yeah. it seems like there should be some collapse.rle one could do as an intermediate step (once adjacent values are the same) instead of inverse.rle => rle
 
@Frank It makes sense.
 
 
3 hours later…
8:25 PM
@akrun I've noticed you are posting tons sqldf answers lately, where is it coming from?
 
8:44 PM
@DavidArenburg Just looking for something new for a change :-)
Yes, I got curious how the sqldf syntax differ from the usual dplyr, data.table solution
@DavidArenburg I think this sqldf solution can be improved. Any ideas?
 
@akrun I'm not so good at SQL. Are you learning it right now or you familiar with it?
 
@DavidArenburg I'm learning it.
 
@akrun that's good. A very usefull language
 
I looked around for how to replace values in a column with some other values in sqldf, but got no links. so from here and there, I got some ideas
 
and should be not too hard
 
8:50 PM
@DavidArenburg BTW, Frank gave a very compact answer ( mat1 | !mat2 ) for his last question. The modification won't be that hard
 
@akrun whos last question?
 
@DavidArenburg I meant giacomoV's question
 
@akrun oh, interesting
though it seems like the have no idea what Im saying
 
@DavidArenburg I think a similar compact option would solve it though I can't find a way for lag. Perhaps embed might be useful
 
9:06 PM
@akrun Its interesting how Frank turned it upside down
i understand his code but its hard to understand why its equivalent to OPs
 
You meant the (mat|!mat2)?
 
@akrun yes
OP wants to & statemnts
Frank flipped mat2 an converted it to one | statment
 
It had to do with logical golfing
2
 
its still hard to understand why these two are equivalent
 
I posted an earlier solution in the comments i.e. similar to the OP's code, i.e. mat1==1 & ...
but I thought Frank's solution is more compact and elegant
@DavidArenburg A simple code is posted now as an answer
 
9:12 PM
@akrun yes, just and embedded for loop, dont think its much different from OPs attempts
I think OP could figure it out himself if theyd payed attention to their own instructions
 
@DavidArenburg I got a compact solution from G.Grothendieck in the comments. A lot to learn in sqldf for me.
 
@akrun yes, you are becoming his favorite :)
 
@DavidArenburg Did you deleted an answer with 7 upvotes yesterday?
I couldn't install the package mentioned in the question as it was not available for my version.
 
@akrun yes, after Rolands comment
I didnt even read the question apperantly
neither the other answrer
 
@DavidArenburg I think he didn't delete it
 
9:21 PM
@akrun I know
dont know why
Roland for some reason didnt comment under his answer
 
I forgot to check today what happened to that post
lubridate faster than baseR?
 
@akrun dont think so
though easy to check
 
Anyway, it would be interesting to know how to change the format for that package without any reduction in performance. I posted an option with substr in the comments, but it will be slower in the end
Probably you have seen this link
 
@akrun no I didn't. Though it seems like lubridate should be faster according to hadley
 
9:37 PM
and that must be the reason that the other post didn't get Roland's reply
 
@akrun probably
 
9:53 PM
@akrun, cane up with this
indx <- mat1 == 1L
mat3[indx] <- (mat2[indx] == 1L) |
              (cbind(mat2[, -1L], FALSE)[indx] == 1L) |
              (cbind(mat2[, -(1L:2L)], FALSE, FALSE)[indx] == 1L)
What do you think?
looks a bit odd, though vectorized
 
@DavidArenburg Is it rbind or cbind`, a bit confused
 
@akrun cbind
i think the for loop will be memory more efficient
especially for many lags
 
I was thinking rbind(FALSE,mat2[-1L,]). May be I didn't go through the loop correctly
 
@akrun his loop is wrong as I pointed in comments
he should loop thru columns instead of rows
the guy in the solution looped thru columns too
 
Okay, then it looks fine. His solution had the pitch of setting any lag
 
10:01 PM
I did a lag here
using cbind
but i dont like it
 
Suppose if the lag is 4,
 
So you''ll need to add | (cbind(mat2[, -(1L:3L)], FALSE, FALSE, FALSE)[indx] == 1L)
 
Ok
 
lame :)
 
as per the post's requirements, your code is good
You should post that
 
10:06 PM
dont think so
it seems like one of these cases when loop is better
at least until Frank wakes up
 
I liked the way G.Grothendieck used na.aggregate here
@DavidArenburg I gtg see u later
 
@akrun k bye
 

« first day (59 days earlier)      last day (3240 days later) »