search for: myarg

Displaying 20 results from an estimated 24 matches for "myarg".

Did you mean: marg
2002 Dec 17
3
Changing "..." inside a function: impossible? desirable?
...with x,y>> points(result, ...) axis(1, ...) axis(2, ...) title(...) } It's clear that some things in "..." can be passed to title() and some to axis(), etc. Of course the above is really silly, but I have a situation where I'd like to see if something, say, `myarg' is part of "..." {piece of cake easy, see below} but then I want to *eliminate* it from "..." such that I can pass "..." down to other functions which would want to see a `myarg' argument. Something like if("myarg" %in% (naml <- names(list(.....
2002 Jun 25
1
commandArgs: feature request
...user-supplied ones. One possible solution would be to augment the return value of commandArgs() with BOOL vector attribute that says whether it is a standard (reserved) R option or not. Here is a usage example that I have in mind: R BATCH --no-save 2001-01-01 3001-01-01 Foo/*.in batch.R batch.R: myArgs <- commandArgs() myArgs <- myArgs[!attr(myArgs, "is.standard")] start <- myArgs[1] end <- myArgs[2] files <- myArgs[-seq(2)] # code ... I am sure there are other (better) solutions, but having anything like this would make it easier to integrate R with shell scripts th...
2006 Oct 03
1
do.call with Vectorial Argument
...fist a function with scalar parameters sigma_pos_old<-function(t,q,lam1,lam2) { q/(lam1-lam2)^2*( (exp(2*lam1*t)-1)/(2*lam1)-2/(lam1+lam2)*(exp(lam1*t+lam2*t)-1) + (exp(2*lam2*t)-1)/(2*lam2) ) } # now the same function where the only argument t is given as a 1x1 vector sigma_pos<-function(myargs) { q/(lam1-lam2)^2*( (exp(2*lam1*myargs[1])-1)/(2*lam1)-2/(lam1+lam2)*(exp(lam1*myargs[1]+lam2*myargs[1])-1) + (exp(2*lam2*myargs[1])-1)/(2*lam2) ) } # Now I use do.call newtime<-seq(1,5,len=1001) mypar<-c(q,lam1,lam2) sig_xx<-do.call("sigma_pos_old",c(list(t=newtime),mypar)...
2009 Jan 03
1
Equivalent of match for data.frame
Dear R-users, I am translating a S script into R and having some troubles with the match function. This function appears to work with vector and data.frame in S, but not in R, e.g.: a <- rep((1:4), each = 10) b <- rep((1:10), times = 4) mydf <- data.frame(a,b) myarg <- mydf[1,] match(myarg, mydf) # S returns 1 but R returns NA NA I guess one could use match(interaction(myarg), interaction(mydf)) to do the job but I was just wondering if there was a more direct function. Thanks, Sebastien
2010 Jan 15
2
processing all files with certain extension in a directory
Hi all, I'm trying to process all files with a certain extension "*.ext" in a directory like this: > R --slave --args /my/dir < dir_plot.r where I then I want to do something like: myarg <- commandArgs() inputdir <- myarg[length(myarg)] print(inputdir) "for file with extension "*.ext in inputdir" do data = process.data(file) outfile = paste(file,".png",sep="") png(outfile,width=3200,height=2400) do.a.plot(data) dev.off() done q()...
2011 May 26
1
Is it possible to define a function's arguments via a wildcard in 'substitute()'?
...ssible to define a function via 'substitute()' such that the function's formal arguments are specified by a "wildcard" that is substituted when the expression is evaluated? Simple example: x.args <- formals("data.frame") x.body <- expression( out <- myArg + 100, return(out) ) expr <- substitute( myFoo <- function( ARGS, myArg ){ print("hello world!") print(ARGS) eval(BODY) }, list(ARGS=x.args, BODY=x.body) ) eval(expr) myFoo(myArg=5) # works myFoo(a=1:3, string...
2017 Jun 06
0
Force argument to have quotes
...6) Why is something like this not suitable: fun1 <- function(a1,a2,a3 = c("hi","by")) { cat(a3,a1+a2,"\n") } > fun1 (1,2) hi by 3 > fun1(1,2, a3 = "whoopee") whoopee 3 ... or, if you want to include the function as an argument of a list: > myArgs <- list(fun=fun1, arglist=list(a1=2, a2 =5, a3 = c("hi","by"))) For which you can do stuff like: > do.call(myArgs[[1]],myArgs[-1][[1]]) hi by 7 > arglist <- myArgs[-1][[1]][-3] > do.call(myArgs[[1]],c(arglist,a3 = "whoopee")) whoopee 7 etc. etc. See...
2012 Jan 18
1
use of UTF-8 \uxxxx escape sequences in function arguments
...arguments, one needs to use UTF-8 escape sequences when calling the function, too - even when working in a UTF-8 locale. Is this an intended behaviour? Here's an example to illustrate the (putative) problem: ## function that uses non-ASCII characters in arguments plain <- function(myarg = c("Basel", "Bern", "Z?rich")) { myarg <- match.arg(myarg) } ## function that uses UTF-8 escape sequences in arguments escaped <- function(myarg = c("Basel", "Bern", "Z\u00BCrich")) { myarg <- match.arg(myarg)...
2006 Nov 24
1
Missing values for S4 slots
Using R 2.4, the following fails: setClass("testc", representation(a="ANY")) makeC <- function(myarg) new("testc", a=myarg) makeC() -> Error in initialize(value, ...) : argument "myarg" is missing, with no default On the other hand, this is OK: f <- function(a) g(b=a) g <- function(b) if(missing(b)) "missing" else "valid arg" g() -> "mis...
2003 Mar 06
1
Proper way to document print( ) functions
Frequently we have a print method, say print.myclass, that has a variety of arguments. If in the .Rd file I say \usage{ \method{print}{myclass}(x, myarg) } I get a warning when running R CMD chk: * checking generic/method consistency ... WARNING print: function(x, ...) print.myclass: function(x, myarg) What is the proper way to handle this? Thanks -- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatist...
2010 Feb 28
1
dots for sample
Dear R-Developers, could 'sample' gain a ... argument? As a convenience function, I added a sample Method to my hyperSpec class. This function however has a flag indicating whether the results should be returned directly as a hyperSpec object or rather as indices that give a random sample. For the moment, I use SetGeneric to add the dots argument, but this of course gives a warning
2017 Jun 06
3
Force argument to have quotes
I am writing a program where non-technical R users will read in a config file and the config file will then parse the arguments found within the config and pass them to respective functions. I'm having trouble (efficiently) writing a piece of code to retain quotation marks around the argument which requires it as input, as found in the example function below, myFuncton1. Below is a minimal,
2014 Apr 14
1
duplication regression (?)
...'t have a use case for it. I stumbled across it when playing with recent changes in R relating to duplication. Does the example use undefined syntax? ----- fn1 <- function(mylist) { fn1a <- function() mylist[[c(1,1)]][[1]] <<- 9 fn1a() return(NULL) } fn2 <- function(myarg) fn1(myarg) test_list <- list(list(list(1))) print(test_list[[c(1,1,1)]]) fn2(test_list) print(test_list[[c(1,1,1)]]) ----- Before r64970 the output is [1] 1 [1] 1 After r64970 the output is [1] 1 [1] 9 > sessionInfo() R Under development (unstable) (2014-04-10 r65396) Platform: x86_64-un...
2006 Feb 03
6
Rails from the command line
I have controller that processes data in one table and puts results in another. Now that its'' working, I would like to be able to run it from the command line ( read: windows batch file). How can this be done? It will be installed on a Windows box with InstantRails1.0, (if that matters). I will be doing more processes like this, so this is a good opportunity to get it right. -- Best
2006 Dec 31
1
Capturing argument values
...object. foo <- function(a, b=1) .... foo(x, 3) match.call() looks promising, but it records that a is x, while I want the value of x (in the calling frame). Also, if the invocation is foo(x), then match.call doesn't record that b is 1. So I tried this (inside the function definition): myargs <- lapply(names(formals()), function(x) eval(as.name(x))) That's pretty close. However, my function has an optional argument in this sense: bar <- function(x, testing) ... where code in the body is if (! missing(testing)) do stuff When the eval in the previous...
2012 Jun 26
1
Packaging Error
...h byte compile set to FALSE. When I set ByteCompile to TRUE, I receive the following error message while doing R CMD INSTALL /usr/lib/R/bin/INSTALL: line 34: 9964 Done echo 'tools:::.install_packages()' 9965 Segmentation fault | R_DEFAULT_PACKAGES= LC_COLLATE=C "${R_HOME}/bin/R" $myArgs --slave --args ${args} I have not been able to understand the problem. Can someone help me understand the problem so that it can be fixed? Thanks, Mayank ________________________________ This email message may contain proprietary, private and confidential information. The information transmitt...
2003 Feb 17
2
returning argument names
Dear r-list folks, I have a problem which has been bugging me for a while now and I was hoping someone out there might be able to help. If I have a user-defined function with an indeterminate number of arguments, using the well-known "..." construct, how can I get the function to return the names of the items which were the arguments of the function as part of the function's
2004 May 14
3
type checking --- just a thought
hi: would it be useful to build into R an optional mechanism that typechecks arguments? for example, sum.across <- function ( inpmatrix : matrixtype( dim[1]>1, dim[2]>3 ) ) : vector { } # this would define a sum.across function that can take matrices or data sets, but not vectors, # and which indicates that it will return a vector. xsum <- sum.across( 1:10
2009 Apr 17
2
suggestion for R >= 3.0: computer-readable CHANGELOG
Hello, Here are a few questions that would be useful to get an answer via dedicated functions in utils or tools packages: - When did function foo appeared in R or in a given package? - When did argument myarg appeared in function foo? - When did function bar get deprecated or when did it disappeared? - I wrote a script using functions foo and bar with R 1.9.1. My script does not work any more with current version. What were all the changes made to foo and/or to bar since then (this could obviously hel...
2006 Dec 27
0
Formatting an arry to typeset as a table
...ient value with the confidence limits below it, e.g.: 5.3 (4.2,6.4) My current thinking is to have a function (possibly a summary method) that takes the output from my functions and returns something that could be passed directly to the latex, odfTable, etc. functions: > myobj <- myfunc(myargs) > latex( summary(myobj), file='mytempfile' ) I prefer to use LaTeX, but many of the people I work with are stuck with MS products so the odf or html options are attractive there. Does anyone have any suggestions on how best to format the output so it can be passed to latex and friend...