Displaying 8 results from an estimated 8 matches similar to: "using do.call to call a list of functions"
2011 Oct 05
4
dynamically creating functions in r
it is possible to dynamically create functions in R using lists? what I want
to do is something like this:
a = list()
for (i in 1:10) a[[i]] = function(seed = i) runif(seed)
so that when I call a[i] I get random draws 1,2,....i unfortunately R only
uses the last i . I would also like to know if there is a run-all function
without explicitly looping or using lapply. for example if I
2011 May 12
1
extract integers from string
I have a vector with a long list of sentences that contain integers. I
would like to extract the integers in a manner such that they are
separate and manipulatable. for example:
x[i] <- "sally has 20 dollars in her pocket and 3 marbles"
x[i+1] <- "30 days ago john had a 400k house"
all sentences are different and contain a mixture of both integers and
characters.
i
2007 Sep 03
4
sin(pi)?
Dear all,
I found something strange when calculating sin of pi value
sin(pi)
[1] 1.224606e-16
pi
[1] 3.141593
sin(3.141593)
[1] -3.464102e-07
Any help and comment should be appreciated.
Regards
Nguyen
____________________________
Nguyen Dinh Nguyen
Garvan Institute of Medical Research
Sydney, Australia
2006 Oct 07
3
ifelse(logical, function1, function2) does not work
Why this kind of assignment does not work?
n <- 1
f <- ifelse(n == 1, sin, cos)
f(pi)
this must be rewritten as:
n <- 1
f <- cos
if (n == 1) f <- sin
f(pi)
[oops. 1.224606e-16 instead of zero. Damn floating point errors :-/]
Alberto Monteiro
2007 Oct 18
3
Writing a R-Script
Ist there a possibility to write a R-Script using something like
#!/usr/bin/R
and then alle the requestet commands?
Of course "R CMD BATCH" exists, but there was (for me) no
possibility to write something like a HERE-script.
regards
erkan
--
?ber den grenzen mu? die freiheit wohl wolkenlos sein
2005 Jun 07
9
how to define functions in such a situation
hi R folks,
I need read a file from hardisk or www web. Then I need to define some
new functions according to the contents of the read file.
For example, i need write a package name "mypackage" like this:
>library(mypackage)
>read(some_file_on_web) #to see its content, suppose it contains:
eat.drink.sleep
then 3 new functions need to be created and usable.
the problem is, how
2011 May 06
1
Generalized Hyperbolic distribution
How to use the package generalized hyperbolic distribution in order to
estimate the four parameters in the NIG-distribution? I have a data material
with stock returns that I want to fit the parameters to.
--
View this message in context: http://r.789695.n4.nabble.com/Generalized-Hyperbolic-distribution-tp3504369p3504369.html
Sent from the R help mailing list archive at Nabble.com.
2011 May 31
1
while loop problems
Hi , i am trying to get this loop in my r program to work but it is
not giving me the results that I desire. I am trying to model an
insurance contract where there are n securities that have a fixed
likelihood of default vector(data[i,2]) and a payout
vector(data[i,1]).
i need to price the value of stop losses at the security level and at
the portfolio level. to do this i created two while loops