Re: [R] Arules Package: Rules subset with 'empty' left hand side (lhs)

2016-09-13 Thread Luisfo via R-help
Dear Tom, I think this is the line you need arules::subset(rules, subset=lhs %pin% "") I found the solution here: http://stackoverflow.com/questions/27926131/how-to-get-items-for-both-lhs-and-rhs-for-only-specific-columns-in-arules One more thing. For printing the rules, I needed the inspect(

Re: [R] get start and end date of ISO weeks giving a date as input

2016-09-08 Thread Luisfo via R-help
Dear Veronica, Here there's a way of doing what you requested. library("lubridate") # your date '2010-08-21' as Date object dd <- as.Date(strptime("2010-08-21", format="%Y-%m-%d", tz="GMT")) # take the first day of the year as Date object, i.e. 2010-01-01 in our example ref.date <- as.Date(strpt

Re: [R] Resample with replacement to produce many rarefaction curves with same number of samples

2016-09-08 Thread Luisfo via R-help
Hi Nick, Yes, you are right. There's one small bug on my code. The 'if' within the for-loop is wrong. Try it now with the code below. rrarefy.custom <- function (x, sample, rep.param=F) { if (!identical(all.equal(x, round(x)), TRUE)) stop("function is meaningful only for integers (counts)

Re: [R] Resample with replacement to produce many rarefaction curves with same number of samples

2016-09-07 Thread Luisfo via R-help
Hi Nick, If you use the following raredata <- rarecurve(rrarefy(netdata, sample=100), label=F, col=rgb(0, 0, 1, 0.1)) should work for any sample size, e.g. sample=100. However, you will have a 'warning' if you don't have samples enough, because it has not replacement. If you type 'rrarefy'

Re: [R] Using apply on a three dimensional matrix and passing multiple arguments to user defined function

2016-09-07 Thread Luisfo via R-help
Hi, Jean's example with lapply works fine. However, if you still want to use apply, I think this works. One observation first. You were passing c(1,2) as second argument to apply, in your code. And that is what makes you have lots of NAs as a result, since your function is being applied twice,