apply

how to sample distributions, given n, distribution name, and parameters in a dataframe?

I have a dataframe: priors <- data.frame(dist = c('lnorm', 'beta', 'gamma'), a = c(0.5, 1, 10), b = c(0.4, 25, 4), n = c(100, 100, 100) ) and I would like to take n samples from the distribution with parameters a and b. I have written this fu...

Can I use apply() with constructor to pass arbitrary number of parameters

I've got a function wich can accept a varible number of parameter with a rest operator. I want create an object passing the argument collected with the rest operator directly to a constructor without create an object and call an initializing function and without passing the entire array but the parameters ah I do with apply() function...

How to use apply, cat and print, without getting NULL

I am trying to use cat() as functions inside apply(). I can almost make R do what I want, but I'm getting some very confusing (to me) NULLS at the end of the return. Here is a silly example, to highlight what I'm getting. val1 <- 1:10 val2 <- 25:34 values <- data.frame(val1, val2) apply(values, 1, function(x) cat(x[1], x[2], fill=TRUE))...

Add styled backgrounds to images in PHP

I am working on improving one of my Facebook apps by allowing the user to upload an image and apply a styled border, or frame to it (i.e. clouds, stars, sky etc). The user chould also be able to save the image, with the border after it has been applied. This explains a little better what I need: http://zbrowntechnology.info/ImgDisp/imgd...

How does javascript eval handle 'this'

I ran tests in Firefox 3.6.11, if that matters, and eval misbehaves in the context of call and apply. It somehow jumps over the current 'this' object. Why? dojo.provide("yal-js.tests.javascript"); function evaltest () { var dis=this; // it works now... returns 2 on call and apply return eval("(function() {return this.testVa...