similar to: Ploting a function of two arguments

Displaying 20 results from an estimated 30000 matches similar to: "Ploting a function of two arguments"

2009 Jun 26
3
changing default arguments of a function and return the modified function as a result
Dear R-users, I am trying to develop a function that takes another function as an argument, changes its default values and returns a list of things, among which the initial function with its default arguments changed. An example of what i will like to obtain below: ## initial function myfun <- function(x, a=19, b=21){ return(a * x + b) } ## this is the function i will like to create ##
2011 Sep 26
4
Testing for arguments in a function
I don't understand how this function can subset by i when i is missing.... ## My function: myfun = function(vec, i){ ret = vec[i] ret } ## My data: i = 10 vec = 1:100 ## Expected input and behavior: myfun(vec, i) ## Missing an argument, but error is not caught! ## How is subsetting even possible here??? myfun(vec) Is there a way to check for missing function arguments, *and*
2009 Mar 19
1
two plots side-by-side with persp3d(rgl)
Dear R-users, I would like to place two 3D plots side-by-side in a rgl-setting. It would nice to have something like "par(mfrow=c(1,2))" for basic plots, or an array framework for wireframe(lattice) (see example below). I only managed to overlap two persp3d plots. My final idea would be to animate both surfaces using play3d(rgl). Thanks in advance for any help. Best, Carlo Giovanni
2007 Feb 23
1
how to use apply with two variables
Hi, this is a made-up example. Function "myfun" returns two arguments. Can "apply" be used so that "myfun" is called only once? Thanks Serguei mat<-matrix(runif(50),nrow=10,ncol=5) myfun<-function(x) { mymean<-mean(x) mysd<-sd(x) return(mymean,mysd) } out1<-t(apply(mat,1,function(x) myfun(x)$mymean)) out2<-t(apply(mat,1,function(x)
2007 May 18
3
lapply not reading arguments from the correct environment
Hello, I am facing a problem with lapply which I ''''think''' may be a bug. This is the most basic function in which I can reproduce it: myfun <- function() { foo = data.frame(1:10,10:1) foos = list(foo) fooCollumn=2 cFoo = lapply(foos,subset,select=fooCollumn) return(cFoo) } I am building a list of dataframes, in each of which I want to keep only column
2004 Dec 15
3
adding perspectives to existing persp plots
I've created a perspective plot using 'persp' in the graphics package. I'd like to add a second plane of z values to the existing plot, but I cannot seem to do this using 'persp'. Is there an analogue to 'lines' or 'points' for perspectives? Corey. corey.bradshaw at cdu.edu.au
2012 Jun 19
2
Smoothing a persp graph
Hi, I'm unable to find a way to smooth data for a persp() graph. Example, suppose that I have data x,y,z like this: x <- 1:10 y <- 1:10 k <- 20 z <- outer(x, y, "*") + matrix( k*runif(100, -1, 1), 10, 10) persp(x, y, z, theta = 35, phi = 25) The graph is not very nice. Is there a way to smooth the z data so that at the end the graph would look more like something
2001 Feb 22
1
Graphical parameters in perspective plot
Hello, I've a problem for setting graphical parameters in perspective plot (function persp). I wonder if it's possible to add some text (function text) on an existing persp plot USING the axis coordinates. In fact I want to add some text on a persp plot according to x coordinates. I've tried to use text(xcoord,ycoord, label="toto") but the toto text doesn't appear at
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.
2012 Jul 05
1
Adding Text to a persp plot using specific coordinates
Hi folks, I'm experiencing some hassle to add some text on a persp plot... Here is the code to generate the persp plot: x <- seq(-1.95, 1.95, length = 30) y <- seq(-1.95, 1.95, length = 30) z <- outer(x, y, function(a,b) a*b^2) persp(x, y, z,xlim=c(-2,2),ylim=c(-2,2),zlim=c(-8,8), phi=30, theta=-30,nticks=8,ticktype="detailed") I've tried the text() function :
2017 Jun 18
0
R_using non linear regression with constraints
I've seen a number of problems like this over the years. The fact that the singular values of the Jacobian have a ration larger than the usual convergence tolerances can mean the codes stop well before the best fit. That is the "numerical analyst" view. David and Jeff have given geometric and statistical arguments. All views are useful, but it takes some time to sort them all out and
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 Sep 27
2
How to pass expression as an argument
Hi, I am writing a function and need to pass a function expression as an argument, for instance, myfun <- function( express) { x<- c(1,2,3) y<-express } if I call the above function by myfun( x*2 ), I get 2 as the result, instead of 2,4,6 , could someone help me to fix this problem ? Furthermore, is that
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.
2002 Aug 01
4
What does persp() return?
I want to plot some 3D points on top of the grid produced by persp(). On 2/22/01, Paul Murrell <paul at stat.auckland.ac.nz> wrote in R-help: > In S-Plus, persp() returns a value that can be used to transform 3D > locations to 2D, but this sort of thing is not (yet) available in R. But persp() does return something (in R-1.5.1): a 4x4 matrix which in the C code is called the
2011 Jun 08
1
3D-plotting a 2D-matrix that contains z-values (3rd dimension)
Hello, say I have a 2D-matrix (indexed by x and y), which contains z values, which I want to plot over x-y. Either dotted, or if possible as a landscape. I tried around with persp and plot3d (from rgl) and persp3d (from rgl). I sometimes get something that looks good and a while later, when trying some new data I need to worry about that again. Is there something lika a convenience function
2013 Jun 07
1
It seams that fast99 function (sensitivity package) does not work out for norm distribution.
Dear all mailing listers, Does Anyone have the same problem as mine when using the fast99 (extended-FAST method) to perform SA of model with norm distribution inputs? See the simple example given following. Any suggestion will be greatly appreciated. Thank you! Marino # Simple example # 1. uniform version (It works well) library(sensitivity) Myfun<-function(x){return(rowSums(x))} SA1
2012 Nov 12
1
3d plotting from a 2d array
Hi, I'm new to R and am learning the ropes of r-help and programming. I'm attempting to plot a 2-D mesh in 3-D using the persp function. I've positioned the graph using phi and theta, but I'm having trouble overlaying color onto the actual surface according to the surface's "z" values. I've tried the "col" feature but it doesn't put a flowing
2006 Apr 19
1
Function to approximate complex integral
I am writing a small function to approximate an integral that cannot be evaluated in closed form. I am partially successful at this point and am experiencing one small, albeit important problem. Here is part of my function below. This is a psychometric problem for dichotomously scored test items where x is a vector of 1s or 0s denoting whether the respondent answered the item correctly (1) or