similar to: Passing a large amount of parameters to a function

Displaying 20 results from an estimated 1000 matches similar to: "Passing a large amount of parameters to a function"

2011 Sep 12
5
completing missing samples
Hello, I have a time-series that has some missing samples. I was thinking on completing them using either zero-order hold or linear interpolation. I am looking for an efiicient way (other than a loop...) of identifiying the missing time slots and filling them. Can you think of any methods that might help here? (obviously which(diff(time)>min(diff(time))) will give the locations, but what
2011 Sep 05
1
capturing a figure to PDF or Image
Hello, I've been using jpeg(), bmp() and pdf() to capture plots. I've used the parameter "at" in a plot, to define the tickmarks. It works fine on screen, but when I try to print it to a file, it gives a warning: "at" is not a graphical parameter and prints an empty figure. Can you help? Thanks, Eran. [[alternative HTML version deleted]]
2011 Aug 30
1
R-Studio Question
Hello, I've switched to R studio from the StatET Eclipse plug-in. I have a question regarding navigating between plots. When I use x11() or windows() new devices are created and I know how to switch back and forth between them. However, when I plot on the device that stands for R-Studio's built-in plot browser, is there a way to switch back between plots? Each new "plot"
2011 Aug 24
2
debugging functions in R
Hi, I am not sure if this is the right list to ask this question (though I did not find a more appropriate one). I've started using R a month ago, and small scripts work fine. However, when I start writing more complex code, it gets messy. 1. Is there any way to debug "normally", with breakpoints? 2. I am using the Eclipse plugin (StatET), and tried JGR(). Is there an IDE that
2011 Sep 01
1
Namespace in packages
Hello, I wonder how I might create a package that only reveals some of the function in the package to the user. I've tried creating an R package using the following: f <- function(x,y) x+y g <- function(x,y) x-y h <- function(x,y) f(x,y)*g(x,y) package.skeleton(list=c("f","g","h"), name="mypkg") and would like only h() to be available when I
2011 Apr 14
1
Possible bug in 'relist()' and/or 'as.relistable()'
Dear list, I think I just stumbled across a bug in either 'relist()' and/or 'as.relistable()'. It seems that 'pairlists' can only be un- and relisted as long as they're not nested: Good: a <- as.relistable(as.pairlist(list(a=1, b=2))) a <- unlist(a) relist(a)# Works Bad: a <- as.relistable(as.pairlist(list(a=1, b=2, c=list(c.1=1, c.2=2)))) a <- unlist(a)
2008 Aug 17
2
Optim stripping attributes from relistable objects
Dear all, The following code is inspired by the help file for the relist() function (see?relist), which explicitly details how you can use a relistable object in conjunction with optim to pass and reconstruct complex parameter structures/groupings. The idea is that the optim() function can only work with vectors, but in many cases you would like to use a complex structure inside the objective
2011 Aug 21
1
How to navigate (zoom, pan) in a plot/graph
Hello all, I need to zoom in and out and "travel"(pan) inside a plot, like you can do on a Matlab plot. If possible, I would also like the option to use the mouse to set a marker on the graph and get the (x,y) data for it, again, like in Matlab. Is this possible in R with the regular packages, or do you maybe know a different package that will allow this? Eran. * * [[alternative
2011 Oct 19
1
using a dictionary in R
Hi all, Is there a way to create a "dictionary" in R, such that it has <key,value> pairs? Something to the effect of: x=dictionary(c("Hi","Why","water") , c(1,5,4)) x["Why"]=5 In truth I'm looking two categorial variables function. So that if x=dictionary(c("a","b"),c(5,2)) x val 1 a 5 2 b 2 I want to compute
2010 Mar 31
2
Simplifying particular piece of code
Hello, everyone I have a piece of code that looks like this: mrets <- merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret="BMM.AV120", stdev="BMM.SD120")) mrets <- merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret="GM1.AV120", stdev="GM1.SD120")) mrets <- merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret="IYC.AV120",
2010 Oct 10
1
Create single vector after looping through multiple data frames with GREP
Hello all, I changed the subject line of the e-mail, because the question I''m posing now is different than the first one. I hope that this is proper etiquette. However, the original chain is included below. I've incorporated bits of both Ethan and Brian's code into the script below, but there's one aspect I can't get my head around. I'm totally new to programming
2011 Feb 18
1
debugger() fails if "..." in function arguments
Dear all, I'm having a problem with debugger() in both R 2.8.0 and R 2.12.0. Probably also versions in-between. I don't see it logged in the bug database, but it's hard for me to imagine that no-one else has encountered it. So my question is whether it's a known problem with a workaround, or do I log it as a new problem? The situation is that if I use
2004 Sep 09
4
scoping rules
Can someone help me with this simple example? sq <- function() { y <- x^2 y } myfunc <- function() { x <- 10 sq() } myfunc() executing the above in R yields: > myfunc() Error in sq() : Object "x" not found I understand that R's scoping rules cause it to look for "x" in the environment in which "sq" was defined (the global environment in
2002 Aug 06
1
re| `By reference'
David Brahm <brahm at alum.mit.edu> wrote: >VBMorozov at lbl.gov wrote: >> I would like to pass variables to a function in R in "by reference"... >Just in case the ensuing discussion got too esoteric, here's one simple answer: >R> x <- 1:10 >R> MyFunc <- function(x, zz) assign(deparse(substitute(zz)), sum(x), 1) >R> MyFunc(x,y) >R>
2009 Aug 06
1
Using 'field names' of a data.frame in a function
I may be doing this wrong! but I have a function which I have simplified a lot below. I want to pass some 'field names' of a data-frame to the function for it to then do some manipulation of. Here's my code: #build a simple dataset mydataset = data.frame (
2002 Aug 03
2
variable scope
Dear R-guRus: I would like to pass variables to a function in R in "by reference", e.g Fortran style. For example, suppose I have the following code x<-c(1:10) y<-1 MyFunc<-function(x,y) {y<-sum(x); return(NULL)} MyFunc(x,y) print(y) in this case print(y) will produce "1" instead of 55 (which is sum(x)) - how do I make sure that afte the function is run, y
2002 Aug 03
2
variable scope
Dear R-guRus: I would like to pass variables to a function in R in "by reference", e.g Fortran style. For example, suppose I have the following code x<-c(1:10) y<-1 MyFunc<-function(x,y) {y<-sum(x); return(NULL)} MyFunc(x,y) print(y) in this case print(y) will produce "1" instead of 55 (which is sum(x)) - how do I make sure that afte the function is run, y
2011 Jan 10
2
Integration in R
Dear all, It has been ages since I studied integration in college. Right now I try to recover all this kind of knowledge and then try to understand how integration works. Thus I am doing some first 'experiments' and I would like to request your help and comments. I have the function: p2<-function(x){0.5*(3*x^2-1)} # I found the square of p2 by using some pencil and
2006 Nov 09
3
function
R-help, I am trying to create a function that i pass a data set to and have the function return some calculations based on data. Allow me to illustrate: myfunc <- function(lst,mn,sd){ lst <- sort(lst) mn <- mean(lst) sd <- sqrt(var(lst)) return(lst,mn,sd) } data1 <-c (1,2,3,4,5) data2 <- c(6,7,8,9,10) myfunc(data1,data1mn,data1sd) myfunc(data2,data2mn,data2sd)
2012 Aug 29
5
Extracting the name of a function (inverse of match.fun("myFun"))
Hi all, is there a way to extract the name of a function, i.e. do the reverse of match.fun applied to a character string? I would like to print out the name of a function supplied to another function as an argument. For example: myFunc = function(x) { x+1 } applyFunc = function(fnc, x) { fnc = match.fun(fnc) fnc(x) } Is there a way to obtain "myFunc" from the argument fnc in