Displaying 20 results from an estimated 200 matches similar to: "Creating functions with a loop."
2009 Mar 23
4
newton method
Hi R-users,
Does R has a topic on newton's method?
Thank you for the info.
2013 Feb 04
2
Modifying a function programmatically
Dear list
# I have a function
ff <- function(a,b=2,c=4){a+b+c}
# which I programmatically want to modify to a more specialized function in which a is replaced by 1
ff1 <- function(b=2,c=4){1+b+c}
# I do as follows:
vals <- list(a=1)
(expr1 <- as.expression(body(ff)))
expression({
a + b + c
})
(expr2 <- do.call("substitute", list(expr1[[1]], vals)))
{
1 +
2011 Mar 15
1
Problem with nls.lm function of minpack.lm package.
Dear R useRs,
I have a problem with nls.lm function of minpackl.lm package.
I need to fit the Van Genuchten Model to a set of data of Theta and hydraulic conductivity with nls.lm function of minpack.lm package.
For the first fit, the parameter estimates keep changing even after 1000 iterations (Th)
and
I have a following error message for fit of hydraulic conductivity (k);
Reason for
2005 Apr 20
3
Keeping factors with zero occurrences in "table" output
Dear R group,
I have a data frame which contains data on preferences on 7 items (ranks 1
through 7) listed by each participant. I would like to tabulate this in a
7x7 table where the rows would be the items and the columns would be the
number of times that item received a particular rank.
I tried doing this by creating a matrix by "rbind"ing each vector obtained
using
2009 Jun 03
2
code for double sum
Hi R-users,
I wrote a code to evaluate double sum as follows:
ff2 <- function(bb,eta,z,k)
{ r <- length(z)
for (i in 1:r)
{ sm1 <- sum((z[i]*bb/2)*(psigamma((0:k)+eta+1,deriv=0)/(factorial(0:k)*gamma((0:k)+eta+1))))
sm2 <- sum((besselI(z[i]*bb,eta)*log(z[i]*bb/2) - sm1)/besselI(z[i]*bb,eta))
sm2
}
ff2(bb,eta,z,10)
but it gave me the following message:
>
2009 Mar 23
2
dput(as.list(function...)...) bug
Tested in R 2.8.1 Windows
> ff <- formals(function(x)1)
> ff1 <- as.list(function(x)1)[1]
# ff1 acts the same as ff in the examples below, but is a list rather
than a pairlist
> dput( ff , control=c("warnIncomplete"))
list(x = )
This string is not parsable, but dput does not give a warning as specified.
> dput( ff ,
2008 Mar 25
6
Prototype 1.6.0.2 + Firefox 3 Enumerable problems
I am using Prototype 1.6.0.2 on Firefox 3.0b4.
The following does not work when I enter it in Firebug:
$A([1,2,3,4]).each(function(n) {alert(n);});
The above is just an example. Any array, using $A and any enumerable
method, returns the following:
TypeError: iterator.bind is not a function
Seems like some objects are not being extended correctly?
Using Prototype 1.5.0 on Firefox 3.0b4, this
2009 Mar 29
9
budgetdedicated server (ubuntu) down?
I was trying to update my wine package because synaptic said there was an update available and I got the following message
W: Failed to fetch http://wine.budgetdedicated.com/apt/pool/main/w/wine/wine_1.1.18~winehq0~ubuntu~8.04-0ubuntu1_amd64.deb
Could not connect to wine.budgetdedicated.com:80 (81.171.111.184). - connect (111 Connection refused) [IP: 81.171.111.184 80]
I also can not connect
2007 Nov 07
1
Aggregate with non-scalar function
R-Helpers,
I'm sorry to have to ask this -- I've not used R very much in the last
8 or 10 months, and I've gotten rusty.
I have the following (ff2 is a subset of a much, much larger dataset):
> ff2
hostName user sys idle obsTime
10142 fred 0.4 0.5 98.0 2007-11-01 02:02:18
16886 barney 0.5 0.2 94.6 2007-10-25 19:12:12
8795 fred 0.0 0.1 99.8
2009 Feb 25
1
monotonic GAM with more than one term
Hi,
Does anyone know how to fit a GAM where one or more smooth terms are
constrained to be monotonic, in the presence of "by" variables or
other terms? I looked at the example in ?pcls but so far have not been
able to adapt it to the case where there is more than one predictor.
For example,
require(mgcv)
set.seed(0)
n<-100
# Generate data from a monotonic truth.
2007 Dec 06
11
Weird Prototype behavior
In this code:
<html>
<head>
<title>PT test</title>
<script type=''text/javascript'' src=''/js/prototype/1.6.0/
prototype.js''></script>
<script type=''text/javascript''>
//<![CDATA[
Event.observe(window, ''load'', function () {
alert($(''login_username''));
});
//]]>
2007 Jun 14
6
Firefox and Thunderbird 2.0, Centos 5, and rpms
I am making some progress on my Centos 5 notebook build.
So I am looking at Firefox and Thunderbird 2.0.
Should I install them? Or is Redhat correct that there is nothing
improved here and wait for 3.0? (well I have not even had a chance to
look at Thunderbird 2.0, that is new)?
I have the install steps we covered here back on 2/2/07; but are there
rpms? I did not find anything over at
2012 Oct 19
2
MLE of negative binomial distribution parameters
I need to estimate the parameters for negative binomial distribution (pdf)
using maximun likelihood, I also need to estimate the parameter for the
Poisson by ML, which can be done by hand, but later I need to conduct a
likelihood ratio test between these two distributions and I don't know how
to start! I'm not an expert programmer in R. Please help
--
View this message in context:
2004 Mar 23
1
nlme question
I have a need to call and pass arguments to nlme() from within another
function. I use R version 1.8.
I have found an apparent way to make this work, but I would appreciate
some comments on whether this fix is really appropriate, or there is
another way to do it that does not involve changing the source code. I
don't have enough experience to start changing the sorurce code of a
library
2008 Jun 20
3
FF3 printing problem on Centos 4.x
I'm using Centos 4.x (fully up to date) on a system at work. I have also
been using firefox 2 (directly from mozilla.org) on it for a long time,
and it tends to work just fine.
yesterday I installed the new FF3 release. It works fine too, with one
exception: The print dialog shows no printers! The print button is greyed
out! There actually four or five printers defined on the system, and all
2004 Apr 18
2
Error in gam?
I'm having some problems using variable names containing spaces (using
backticks) with gam (mgcv 0.9-6, R 1.8.1). Some toy code to reproduce
my problem is below. Am I doing something wrong, or should I pass this
bug on to Simon Wood? (Or do I need to rename my variables to get rid of
the spaces?)
Thanks,
Hadley
library(mgcv)
test <- data.frame(a = c(1:10), `a b` = c(1:10)^2,
2008 Jan 31
2
Odd things happening in ie6/ie7
As always, i am again having problems in IE6 and IE7 with scripts.
The scripting works fine in FF2, opera and Safari. IE just wont load
it. Could anyone help?
It''s a static page for now, located at www.maifith.com/research/index.html
The problem,although quite obvious, is that it doesn''t load the JS in
IE6 or IE7. Any help would be appreciated.
2007 Mar 04
23
Sound support for script.aculo.us
Hi all,
I''ve added a new library called sound.js to script.aculo.us, which
allows for playing (mp3-based) sound effects. It works without using
Flash, by using IE''s internal sound playback mechanism (BGSOUND) and
falling back on using whatever plugin is used for audio/mpeg on other
browsers (in real world terms, this means QuickTime or a QuickTime-
compatible plugin).
2009 Aug 07
1
Gauss-Laguerre using statmod
I believe this may be more related to analysis than it is to R, per se.
Suppose I have the following function that I wish to integrate:
ff <- function(x) pnorm((x - m)/sigma) * dnorm(x, observed, sigma)
Then, given the parameters:
mu <- 300
sigma <- 50
m <- 250
target <- 200
sigma_i <- 50
I can use the function integrate as:
> integrate(ff, lower= -Inf, upper=target)
2008 Mar 25
2
a JavaScript front-end for Babelmark
Hi,
I've built a quick-and-dirty diff GUI for Babelmark (thanks,
Michel!). You can get it as a bookmarklet here:
http://attacklab.net/babelmark/
If either Michel or Tom is interested in hosting this, I'll be happy
to do the grunt work for a real integration. It's kind of pain in the
ass to hit the bookmarklet every time you get new data from the server.
I've tested this