similar to: How to pass expression as an argument

Displaying 20 results from an estimated 20000 matches similar to: "How to pass expression as an argument"

2007 Jan 09
4
A question about R environment
Hi all, I created environment "mytoolbox" by : mytoolbox <- new.env(parent=baseenv()) Is there anyway I put it in the search path ? If you need some background : In a project, I often write some small functions, and load them into my workspace directly, so when I list the objects with ls(), it looks pretty messy. So I am wondering if it is possible to creat an
2007 Feb 02
2
A question about dput
Hi, I am trying to output a R data set for use in WinBugs, I used dput(list(x=rnorm(100),N=100),file="bug.dat") But I can't get the intended format: list(x=c(.......),N=100), instead, I got something like this (copied the first two lines): [00000000]???73?74?72?75??63?74?75?72??65?28?6C?69??73?74?28?78???? structure(list(x
2007 Jan 14
1
Questions about paste and assign
Hi, I would like to assign a value to a member b of the list a in position 3, by calling: assign( target, 2.34, 3) My question is what the "target" should be. I tried target <- paste("a", $, "b") and something else, but haven't got the right answer yet. BTW, if I attached a list named
2007 Apr 01
1
Keep R packages in the R installation
Hi, I just got a quick question here, when I install a new version of R , is there an easy to keep the installed R packages ? Thanks a lot for any help. tong
2005 Jun 28
2
How to import data as numeric array?
Did some search but couldn't find useful result. I am trying to read a n*m dimension data with read.table, what i need is a numeric array, is there any efficient way to allow me get this array directly instead of a list? I tried to use as.array() to change the mode, but seems it doesn't work and i got this error message: "Error in "dimnames<-.data.frame"(`*tmp*`,
2007 Apr 02
2
Compiling C codes in Windows
Hi All, I have been struggling to figure out how to compile c codes for R use. I am using Win XP + Cygwin + R binaries. After I followed all the instructions in " Building R for Windows" from Murdoch's website, I tried to Run something like : R CMD SHLIB C:\R\test.c , but still didn't get any output. My first question is, does this mean I already did
2007 Apr 02
2
Compiling C codes in Windows
Hi All, I have been struggling to figure out how to compile c codes for R use. I am using Win XP + Cygwin + R binaries. After I followed all the instructions in " Building R for Windows" from Murdoch's website, I tried to Run something like : R CMD SHLIB C:\R\test.c , but still didn't get any output. My first question is, does this mean I already did
2006 Mar 17
1
How to change the label in plot.ts ?
Hi you guys: I have been wondering if there is any way to change the labeling in plot.ts( ), for example , if I plot two sequences, i always got y labels as "series1", "series2", I tried to use ylab=c((expression(mu_1)),(expression(mu_2))), but it doesn't work. thanks in advance for any help best.
2006 Oct 28
1
A quesiton on data manipulation
Hi, I have a data set (data frame) describing some features of the students in a high school in the following format: Stu ID Year feature 1 feature 2 ............. 1001 1990 1001 1991 1001 1992 1002 1990 1002 1991 1002 1992 Some features of a few of these students are missing, I would like to
2007 Jan 04
1
need help with debug package
Hi all, I met a problem while using the debug package, I have the following program: mainfun<- function(){ beta<-1 result<-subfun(beta+x) } subfun<-function(expr){ y <- eval(expr, envir=list(x=c(1,2)),enclos = parent.frame()) return(y) } I have no problem using this program without calling the debug
2007 Dec 27
1
Efficiency of for-loop in R
Hi, I just realized that in Matlab, as long as memory is pre-allocated, doing for-loop doesn't cost more time than doing things in vector form. But it seems in R, it still cost a lot to do for-loop. Is there any improvement in R that I missed. Thanks a lot. Merry Xmas Everyone !
2011 Jul 23
1
call a function with explicitly not setting an argument
Is there a way to call a function, and explicitly set an argument to 'not specified'? My situation is the following. I have a function which passes on most of its arguments to another function. The second function, myfun2, serializes all arguments and is out of my control. myfun <- function(...){ return(myfun2(...)); } now, the value for arguments of myfun are stored in variables.
2011 Feb 02
1
pass nrow(x) to dots in function(x){plot(x,...)}
Dear Rers, I have a function to barplot() a matrix, eg myfun <- function(x, ...) { barplot(x , ... )} (The real function is more complicated, it does things to the matrix first.) So I can do: m1 <- matrix(1:20,4) myfun(m1) myfun(m1, main="My title") I'd like to be able to add the number of rows of the matrix passed to the function to the "..." argument, eg
2006 Apr 20
1
Bootstrap error message: Error in statistic(data, origina l, ...) : unused argument(s) ( ...)
> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Michael > Sent: Thursday, April 20, 2006 3:50 AM > To: R-help at stat.math.ethz.ch > Subject: [R] Bootstrap error message: Error in > statistic(data, original, ...) : unused argument(s) ( ...) [Broadcast] > > > Dear colleagues, >
2006 Aug 16
1
Problem with the special argument '...' within a function
I'm not sure if this is what you want, but simply add ... to the list of arguments for fun1 and fun2 would eliminate the error. Andy From: Hans-Joerg Bibiko > > Dear all, > > I wrote some functions using the special argument '...'. OK, it works. > > But if I call such a function which also called such a > function, then I get an error message about unused
2003 Apr 17
4
A function as argument of another function
Dear all, I would like to write a function like: myfun<-function(x,fn) {xx<-exp(x); x*fn(xx)} where fn is a symbolic description of any function with its argument to be specified. Therefore myfun(5,"2+0.3*y^2") should return 5*(2+0.3*exp(5)^2), myfun(5,"log(y)") should return 5*log(exp(5)) and so on. I tried with "expression" and others, but without success.
2018 Nov 29
3
Unexpected argument-matching when some are missing
On Thu, Nov 29, 2018 at 10:51 AM S Ellison <S.Ellison at lgcgroup.com> wrote: > > > When trying out some variations with `[.data.frame` I noticed some (to me) > > odd behaviour, > > Not just in 'myfun' ... > > plot(x=1:10, y=) > plot(x=1:10, y=, 10:1) > > In both cases, 'y=' is ignored. In the first, the plot is for y=NULL (so not
2018 Nov 29
4
Unexpected argument-matching when some are missing
When trying out some variations with `[.data.frame` I noticed some (to me) odd behaviour, which I found out has nothing to do with `[.data.frame`, but rather with the way arguments are matched, when mixing named/unnamed and missing/non-missing arguments. Consider the following example: myfun <- function(x,y,z) { ? print(match.call()) ? cat('x=',if(missing(x)) 'missing'
2007 May 13
1
Strange behavior of debugger
Hi, All: I had some trouble debugging C source dynamically loaded into R , when I issued N in gdb(or insight) , the debugger, instead of moving downward step by step, jumped to strange positions (upward, downward, one step, a few steps away). To enter the debugger, I issued gdb(insight) Rgui.exe in Cygwin and add this line : asm("int $3"); to my C code. After entering R, I
2004 Mar 11
1
how to pass extra parameters using call() or similar mechanism ?
I am trying to write a function, which would allow to call various methods and would pass to them extra arbitrary parameters. My first attempt was to use call() as illustrated below, but apparently '...' cannot be used in such context. How can this be achieved ? Best regards, Ryszard > myfun <- function(method, x, ...) { + v <- eval(call(method, x, ...)) + } > method =