> It wouldn't be guaranteed to produce any usable permutation, but it seems
> like it would be much faster and so could be repeated until an acceptable
> vector is found. What do you think?
>
> Thanks--
> Andy
>
I think I am not understanding what your ultimate goal is so I'm not
sure I can give
I just realized I read through your email too quickly and my script does
not actually address the constraint on each permutation, sorry about that.
You should be able to use the permutations function to generate the vector
permutations however.
Jason
ation then ?
gtools::combinations).
Hope this helps,
Jason Smith
Here is the script I used:
# Constraint
# f(n_i) <= 2 * f(n_(i-1))
#
# Given a start value and the number of elements
# recursively generate a vector representing the
# maximum values each index is allowed
#
f <- function(value, num
Dimitri Liakhovitski gmail.com> writes:
>
> One follow up question - the proposed solution was (notice - this time
> I am introducing one NA in data frame "x")
>
> x<-data.frame(factor=c("b","b","d","d","e","e"),values=c(1,NA,10,20,100,200))
> x$std.via.ave<-ave(x$values, x$factor, FUN=functio
Here is one approach if I understand your requirements correctly.
ind1<-c(1,4,10)
ind2<-c(3,5,11)
m <- expand.grid(ind2=ind2,ind1=ind1)
m$diff <- (m$ind2 - m$ind1)
f <- function(x) {
min_idx <- which.min(x$diff[x$diff > 0 & x$diff < x$ind2])
list(c(elem=unique(x$ind2),min.value=x$i
Here is how I tried to do a simple side-by-side boxplot:
# Create new dataframe (cultivar, values, idx)
# cbind goes by column so the cn column is repeated for us
cultivars <- cbind(cultivar=wheat$cn, stack(wheat[2:15]))
boxplot(values ~ cultivar, data=cultivars,
main="Kernel distribution"
6 matches
Mail list logo