Displaying 20 results from an estimated 800 matches similar to: "Passing function arguments to dataset names"
2012 Nov 09
2
TreynorRatio
i read about the performance analytics package
i have a doubt about the TreynorRatio
i have code
g=getSymbols("IBM")
> c=Cl(g)
> r=Return.calculate(c)
> SharpeRatio.annualized(r)
IBM.Close
Annualized Sharpe Ratio (Rf=0%) 0.3566339
> TreynorRatio (ret)
Error in inherits(x, "xts") : argument "Rb" is missing, with
2005 Dec 14
2
The fastest way to select and execute a few selected functions inside a function
Dear useRs?
I have the following problem! I have a function that calls one or more
functions, depending on the input parameters. I am searching for the fastest
way to select and execute the selected functions and return their results in
a list. The number of possible functions is 10, however usually only 2 are
selected (although sometimes more, even all).
For examples, if I have function
2018 May 03
2
Calling the curve function with a character object converted into an expression
Hi,
Down a cascade of function calls, I want to use the curve function with an expression that is a variable. For various reason, this variable must be a character object and cannot be an expression as required by the curve function. How do I convert my variable into a expression that is accepted by curve?
Thanks in advance for your help.
## The following attempts do not work
myf <-
2005 Nov 23
3
Infinite recursion in S3 methods crashes R on windows (related to PR#8203?)
Hi,
Infinite recursion in S3 methods seem to crash R on Windows 2000 (R
terminating with the ("Rgui.exe has generated errors...") message,
rather than throwing an error. This happens with both Rgui and Rterm.
The following toy example triggers this:
myf <- function(x, ...)
UseMethod("myf")
myf.default <- function(x, ...)
myf(x)
myf(1)
...R crashes...
Which I
2011 Feb 22
1
Discrepancies in run times
Dear R-users,
I am in the process of creating new custom functions and am quite puzzled by
some discrepancies in execution time when I run some R scripts that call
those new functions. So here is the situation:
- let's assume I have created two custom functions, called myg and myf;
- myg is mostly a plotting function, which makes a heavy use of grid and
lattice functions;
- myf is a function
2018 May 03
0
Calling the curve function with a character object converted into an expression
Sebastian:
This is somewhat arcane, perhaps even a bug (correction on this
welcomed). The problem is that the "expr" argument to curve() must be
an actual expression, not a call to parse that evaluates to an
expression. If you look at the code of curve() you'll see why
(substitute() does not evaluate expr in the code). Another simple
workaround other than sticking in the eval()
2012 Nov 06
1
how Can make function for selecting the products
HI.
I make this code:
getdata<-function('a','b','c' ,'d','e','f'){
drv <- dbDriver("SQLite")
con<-dbConnect(drv, "sqlite.db")
lt<-dbListTables(con)
myf<-data.frame(NULL)
for (i in 1:length(lt))
{
myfile<-dbReadTable(con,lt[i])
myfile1<-myfile[-c(14:44)]
myfile1$MODEL<-gsub(" ",
2018 May 03
1
Calling the curve function with a character object converted into an expression
Typo: should be NULL not NUL of course
An alternative approach closer to your original attempt is to use
do.call() to explicitly evaluate the expr argument:
w <- "1 + x^2"
do.call(curve, list(expr = parse(text = w), ylab ="y"))
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along
and sticking things into it."
-- Opus
2010 Dec 18
3
use of 'apply' for 'hist'
Hi all,
##########################################
dof=c(1,2,4,8,16,32)
Q5=matrix(rt(100,dof),100,6,T,dimnames=list(NULL,dof))
par(mfrow=c(2,6))
apply(Q5,2,hist)
myf=function(x){ qqnorm(x);qqline(x) }
apply(Q5,2,myf)
##########################################
These looks ok.
However, I would like to achieve more.
Apart from using a loop,
is there are fast way to 'add' the titles to be
2011 Feb 03
1
Getting variable names in function output
Dear R-users,
I would like to have some advises about a problem illustrated by the
following snippet. Within myf, I need to evaluate a piece of R code that is
passed as a character argument and then return the objects that are created
by this code. The difficulty comes from the fact that the content of the
code is variable and unknown to me (obviously not in this illustration!).
With the
2010 Dec 01
3
RFC: sapply() limitation from vector to matrix, but not further
sapply() stems from S / S+ times and hence has a long tradition.
In spite of that I think that it should be enhanced...
As the subject mentions, sapply() produces a matrix in cases
where the list components of the lapply(.) results are of the
same length (and ...).
However, it unfortunately "stops there".
E.g., if you *nest* two sapply() calls where the inner one
produces a matrix, very
1999 Jan 16
1
Core dump on sapply misuse
Developers:
I hope this is the appropriate place to post this request.
I am getting a core dump in an application of sapply. A
simplified example is the following. Because simplify=TRUE
is the default for sapply and tapply, the following works
x <- 1:5; sapply(x,list)
but the following dumps core with an access violation
x <- 1:5; myf <- function(x) list(x,x); sapply(x,myf)
2004 Apr 05
3
Evaluation of functionals
Suppose I have
f1 <- function(x) x
f2 <- function(x) x^2
funlist <- list(f1,f2)
Then I would like to evaluate funlist such that when x is 10 I should get a list with 10 and 100.
A naive way of doint this is
myf <- funlist[[1]]
do.call(paste(quote(myf)), list(x=10))
myf <- funlist[[2]]
do.call(paste(quote(myf)), list(x=10))
- but there has to be much
2003 Jul 30
2
Plotting a function with curve()
Why does
> curve(function(y) y^2, from=0,to=1)
not work, whereas
> myf <- function(y) y^2
> curve(myf, from=0,to=1)
work?
For the former, I get the error message
Error in curve(function(y) y^2, from = 0, to = 1) :
'expr' must be a function or an expression containing 'x'
I'm using R1.7.0 under Windows XP.
Damon Wischik.
2010 Apr 13
3
writing function ( 'plot' and 'if') problem
===========================
myf=function(ds=1){
x=rnorm(10)
y=rnorm(10)
{ #start of if
if (ds==1)
{
list(x,y)
}
else (ds==2)
{
plot(x,y)
}
} # end of if
} # end of function
===========================
Hi All,
the problem i am having here is,
that I want to be able to control the display,
lf ds=1, i want to just have a list,
but it seem to always plot...
Thanks.
casper
--
View this
2016 Feb 15
2
[PATCH 23/23] nvc0: implement support for maxwell texture headers
Can you push this to a repo somewhere? I want to see what the final
version looks like after all your changes, but it's hard to see that
with these patches.
On Mon, Feb 15, 2016 at 12:38 AM, Ben Skeggs <skeggsb at gmail.com> wrote:
> From: Ben Skeggs <bskeggs at redhat.com>
>
> Adds support for the new TIC layout that's present on Maxwell GPUs,
> heavily based on
2024 Jan 11
4
arrow on contour line
Hello,
I am drawing contour lines for a function of 2 variables at one level of
the value of the function and want to include a small arrow in any
direction of increase of the function. Is there some way to do that?
Below is an example that creates the contour lines. How do I add one small
arrow on each line in the direction of increase of the function (at some
central point of the contour
2006 Dec 14
1
Reverse order of grouping factor in grouppedData
I created the following groupedData object (nlme library):
gd <- groupedData(Conc ~ Time | Subj,
order.groups=T,
FUN = myf,
data=mydata)
The idea of the myf function is to reverse the order of the grouping factor
Subj (or better, reorder from largest to smallest). In the mydata data set,
Subj is an integer that gets converted into a factor in the groupedData
object.
Does anyone
2007 Dec 14
1
Function built with segments
Hello,
I'm new to R. If I have a set of 10 points (X(i), Y(i)), is there an elegant
way to build a function y=f(x) that would be build out of the consecutive
segments of X(j),Y(j) points (with X(j) sorted)?
Thank you very much
TDB
--
View this message in context: http://www.nabble.com/Function-built-with-segments-tp14337780p14337780.html
Sent from the R help mailing list archive at
2005 Oct 25
8
Can anyone please tell me how to strip the white spaces from a character vector?
for example:
> a$tic[1:10]
[1] "AIR " "ABCB " "ABXA " "ACMR " "ADCT " "ADEX "
[7] "ABM " "AFCE " "AG " "ATG "
Can anyone please tell me how to strip the white spaces from a$tic?
Thanks,
Roger
[[alternative HTML version deleted]]