[R] R code debugging
Dear useRs, it's quite difficult for me to find `Error:'s in my R code, because R does say about error itself, but say nothing about its location, say, string number and file with an error (which may be `source'd from another file). Are there any option for turning of the similar feature, or R can not do such a thing at all? Thanks. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] non-linear solve?
From: [EMAIL PROTECTED] Date: Tue 02 Nov 2004 - 00:55:31 EST hi: could someone please point me to a function that allows me to solve general non-linear functions? irr.in - function(r, c1, c2, c3 ) { return(c1+c2/(1+r) + c3/(1+r)^2); } solve.nonlinear( irr.in, -100, 60, 70 ); 0.189 If someone has written an irr function, this would be helpful, too---though not difficult to write, either. thanks for any pointers. Regards, /iaw optim, nlm - for general optimization; nls, nls.lm from `minpack.lm' package - for solving the least-squares problem. -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] [R-pkgs] R interface for MINPACK least squares optimization library
Hello guys. I've built and uploaded to CRAN an R interface to MINPACK Fortran library, which solves non-linear least squares problem by modification of the Levenberg-Marquardt algorithm. The package includes one R function, which passes all the necessary control parameters to the appropriate Fortran functions. The package location is http://cran.r-project.org/src/contrib/Descriptions/minpack.lm.html Best wishes, Timur. ___ R-packages mailing list [EMAIL PROTECTED] https://stat.ethz.ch/mailman/listinfo/r-packages __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] R mathlib
Hello, dear R experts! I run R on Debian 'sarge' platform. There is 'r-mathlib' package in Debian distribution, which is described as: $ dpkg --status r-mathlib ... This packages provides the libRmath shared and static libraries which can be called from standalone C or C++ code. Well, I use runif() function in test_runif.c: #include Rmath.h main() { // ... printf(%f\n, runif(0, 1)); } and compile it: $ gcc -I/usr/lib/R/include -lRmath -lm -o test_runif test_runif.c /tmp/ccmICWeD.o(.text+0x2d): In function `main': : undefined reference to `Rf_runif' collect2: ld returned 1 exit status Replacing `-lm' with `-lR' solves the problem. So, I need libR.so anyway? Thanks. -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Tutorial for graphics
On Wed, Jun 16, 2004 at 10:12:49PM -0400, Phil wrote: I'm coming to R from Matlab and I'm finding it difficult to find a good introduction to graphics in R. (The best I've found so far is Ch. 4 of Emmanuel Paradis R for Beginners. Still, I have been unable to discover simple things like how to resize the axes on an existing plot I'm afraid it's not possible to resize existing axis, by mouse. But if you want to add the another plot with differnet scale, you could do it this way: plot(...)# you normally plot 1st graph par(new = TRUE) # 2nd graph won't clean the frame plot(..., axes = FALSE, xlab = , ylab = ) # plotting 2ng graph axis(4) how to add (or change) axis labels on an existing plot, etc. You can plot without axes plot(..., axes = FALSE), then add axes, with labels or not, ticks with any length, and so on. Can anyone point me to a suitable tutorial, or even tell me how to perform those tasks? help(plot.default) help(par) Also, Matlab's graphical widget has the ability to zoom (and unzoom) by drawing a rectangle on the graph with the mouse. Is there anything similar in R? Probably there are R packages perfoming such a thing, but I do not use R interactively at all. I change xlim() and/or ylim() in R script, and source() it again :) -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] .First() in R 1.9.0
Dear R experts, I just upgraded R from 1.8.1 to 1.9.0 version. My .First() function in ~/.Rprofile contains x11() and par() functions. .First - function() { x11(display = , 8.0, 5.0) par(las = 1, ...) ## ... } And, R claims now, on startup: [hello messages skiped ...] Error in .First() : couldn't find function x11 I commented x11 string, and get the same error about par: Error in .First() : couldn't find function par There was no such a problen with previos R version. Why .First function knows nothing about x11 and par functions? Thanks. -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] par() usage
Dear R experts. I saw in a lot of examples the following R code: x11() op - par(no.readonly = TRUE) par(op) Warning message: calling par(new=) with no plot Why I get a warning? I'm doing something wrong? Thank you! -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] creating a ps. file
On Mon, Mar 15, 2004 at 12:37:02PM +0100, [EMAIL PROTECTED] wrote: I wrote a routine. At the end of each cycle of the loop I would like to save the result (plot) in a postcriptfile. Of course if I just use dev.print in the following way: dev.print(device=postcript, 'c:/Rfigures/plot_1.ps) I overwrite my results with the second cycle of the loop. I suppose there is a way to define the file name so that several plots are created(plot_1,plot_2...). Could you give me an advice? Thanks a lot for (i in 1:10) { x11(); plot(...) ... dev.copy2eps(file = paste(plot_, i, .eps, sep = )) } -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Simple numeric as.is question
On Mon, Mar 15, 2004 at 09:04:05AM -0500, Janet Gannon wrote: I am reading a list of numbers from my clipboard, and have been successful, except I can't make a histogram as R doesn't recognize my variable as numeric. I know I need to use as.is, but the specifics escape me. I have used x-read.table(clipboard, header=F) to import from a txt file. How do make this numeric? Thanks, J. x - read.table(clipboard, header=F) x - as.data.frame(lapply(x, as.numeric)) -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] How to save images?
On Fri, Feb 27, 2004 at 08:05:10AM -0800, Susan Lin wrote: After I use function plot() to get an image, how can I save the image or export it to .gif or other digital formats? ?device -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] no subject
On Tue, Feb 24, 2004 at 02:34:35PM +0100, Claudia Paladini wrote: Dear ladies and gentlmen, I want to import a directory with about 400 files (.dat) in R. I know how to import a single file (with scan...) but I've good no idea how to import 400 at once. Can you help me ? You can get list of the files you need: flist - system(ls, intern = TRUE) Then run on that list: for (fname in flist) { get(fname, scan(file = fname, ...)) ... } -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] no subject
On Tue, Feb 24, 2004 at 05:11:07PM +0300, Timur Elzhov wrote: Dear ladies and gentlmen, I want to import a directory with about 400 files (.dat) in R. I know how to import a single file (with scan...) but I've good no idea how to import 400 at once. Can you help me ? You can get list of the files you need: flist - system(ls, intern = TRUE) flist - system(ls *.dat, intern = TRUE) in your case, you see :) -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Obtaining SE from the hessian matrix
On Thu, Feb 19, 2004 at 09:22:09AM -0800, Thomas Lumley wrote: So, what is the _right_ way for obtatining SE? Why two those formulas above differ? If you are maximising a likelihood then the covariance matrix of the estimates is (asymptotically) the inverse of the negative of the Hessian. The standard errors are the square roots of the diagonal elements of the covariance. So if you have the Hessian you need to invert it, if you have the covariance matrix, you don't. Yes, the covariance matrix is inverse of the Hessian, that's clear. But my queston is, why in the first example: sqrt(diag(2*out$minimum/(length(y) - 2) * solve(out$hessian))) The 2 in the line above represents the number of parameters. A 95% confidence interval would be the parameter estimate +/- 1.96 SE. We can superimpose the least squares fit on a new plot: - we don _not_ use simply 'sqrt(diag(solve(out$hessian)))', how in the second example, but also include in some way number of parameters == 2? What does '2*out$minimum/(length(y) - 2)' multiplier mean? Thanks! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Obtaining SE from the hessian matrix
Dear R experts, In R-intro, under the 'Nonlinear least squares and maximum likelihood models' there are ttwo examples considered how to use 'nlm' function. In 'Least squares' the Standard Errors obtained as follows: After the fitting, out$minimum is the SSE, and out$estimates are the least squares estimates of the parameters. To obtain the approximate standard errors (SE) of the estimates we do: sqrt(diag(2*out$minimum/(length(y) - 2) * solve(out$hessian))) But under 'Maximum likelihood' section I've read: After the fitting, out$minimum is the negative log-likelihood, and out$estimates are the maximum likelihood estimates of the parameters. To obtain the approximate SEs of the estimates we do: sqrt(diag(solve(out$hessian))) As for me, I use MINPACK fortran library for NLS fitting in R, and there I also get the hessian matrix. What formula should I use in _this_ case? Well, some times ago I had a glance at gsl, GNU Scientific Library. It use converted-to-C MINPACK for NLS fit too. And, in the GSL ref. manual example http://www.gnu.org/software/gsl/manual/html_node/gsl-ref_36.html#SEC475 SE calculated as #define ERR(i) sqrt(gsl_matrix_get(covar,i,i)) where covar = (J^T * J)^-1 (i.e. how in the second formulae above). So, what is the _right_ way for obtatining SE? Why two those formulas above differ? Thank you! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] lm coefficients
On Tue, Feb 03, 2004 at 05:27:40PM +, Prof Brian Ripley wrote: out - lm(T ~ poly(X, 4), data = d) You asked for 4 and got 2? Really? No, in fact I have a 4-power model, I just posted example with power of 2, for simplicity. I forgot to replace the poly argument :) Thanks too all who helped me! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R: plotting multiple functions
On Tue, Feb 03, 2004 at 09:59:31AM +0200, allan clark wrote: Another simple question. I would like to plot three graphs one the same plot with different colours. Say red, blue and black. Here are the functions. r1-1+5*cos(2*pi*seq(1:100)/20)+rnorm(100) r2-1+7*sin(2*pi*seq(1:100)/20)+rnorm(100) r3-1+7*sin(2*pi*seq(1:100)/20)+5*cos(2*pi*seq(1:100)/20)+rnorm(100) plot(r1, type = n) points(r1, col = red, pch = 19) ## see also ?lines points(r2, col = blue, pch = 19) points(r3, col = black, pch = 19) __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] lm coefficients
Dear R experts, Excuse me if my question will be stupid... I'd like to fit data with x^2 polynomial: d - read.table(file = Oleg.dat, head = TRUE) d X T 3720.00 4.113 3715.00 4.123 3710.00 4.132 ... out - lm(T ~ poly(X, 4), data = d) out Call: lm(formula = T ~ poly(X, 2), data = d) Coefficients: (Intercept) poly(X, 2)1 poly(X, 2)2 9.803 -108.075 51.007 So, d$T best fitted with function 9.803 -108.075 * X + 51.007 * X^2, yes? T1 - 9.803 -108.075 * d$X + 51.007 * d$X^2 T1 705453240 703557595 701664500 699773956 ... So, T1 obviosly gets non-sensible values.. :( Why? Thanks a lot! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] derivative of atan(x) and similar functions
Dear R experts. 'D()' function recognizes some of the analitical functions, such as sin, cos, etc. But I'd like to take analytical derivatives from asin, atan etc. functions. Are there any R packages providing that features? Thanks. -- Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] analytic derivative of complex function
Hello, Robin. Thanks for your reply. -- On Fri, Jan 16, 2004 at 03:39:48PM +, Robin Hankin wrote: the differential of sin(z) is cos(z), over the whole complex plane. If you have a function in terms of its real and imaginary components, and you know that the function is differentiable, then use the Cauchy-Riemann equations. Ok, say I have z - _extremely_ long and hard complex _expression_. What if I'd like to take analytic derivative from Arg(z)? -- Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] analytic derivative of complex function
Dear R experts, I'd like to take analytic derivative of complex functions through D function. I succeded with simple functions like sin(x), but what if I want to work with function like A(x,y, ...) + i*B(x,y, ...)? Thank you. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] R comparison
On Sun, Nov 23, 2003 at 11:38:05AM +, Florian Roedhammer wrote: I would need information concerning the features of R such as static/dynamic typing, method overlapping, object oriontation, My question is whether you know any site where such features are discussed on or if you could help me directly. Have you had a look at http://cran.r-project.org/doc/manuals/R-lang.pdf ? -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] problem with x11 and PS devices on different machines
Dear R help, I run R at home and the work, I have Debian Linux on both machines and the same 'r-base-core' deb packages installed. So I tried to run the same R script, which plots graph in x11 device and then dump it to eps file (x11 and eps you'll find attached). On the home machine there are some stranges in x11 plot as well as in eps file. On the work machine all the ok, despite of that I use the _same_ version of binary deb package. May be any troubles with the font paths? Thank you in advance for any suggestions! -- WBR, Timur attachment: x11-bad.pngattachment: x11-good.png__ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] problem with x11 and PS devices on different machines
On Wed, Nov 12, 2003 at 05:26:51PM +0700, Philippe Glaziou wrote: I run R at home and the work, I have Debian Linux on both machines and the same 'r-base-core' deb packages installed. So I tried to run the same R script, which plots graph in x11 device and then dump it to eps file (x11 and eps you'll find attached). On the home machine there are some stranges in x11 plot as well as in eps file. On the work machine all the ok, despite of that I use the _same_ version of binary deb package. May be any troubles with the font paths? Thank you in advance for any suggestions! x11-good.png: PNG image data, 600 x 420, 8-bit/color RGB, non-interlaced x11-bad.png: PNG image data, 449 x 315, 8-bit/color RGB, non-interlaced Right, bad x11() picture is smaller. These 'png' are simply their screen shots (made by gimp). It could be that your X11 Modes differ between both machines, with a different number of dots per inch. I use the same resolution, 1024x768 on both machines. Anyway, I do not think that xserver resolution is important for screenshot size (in pixels) :) -- Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] problem with x11 and PS devices on different machines
On Wed, Nov 12, 2003 at 07:14:01PM +0700, Philippe Glaziou wrote: The width and height of a default R x11 plotting window are both 7 inches. There will be a different number of dots within those 7x7 square inches if the number of dots per inch is not similar. This could be the case even though your two xservers are set at 1024x768. Does 'xdpyinfo | grep dots' return the same numbers on both machines? I see :) I am in the office now, but I tried to play with dpi. I used to think that dpi _is_ resolution / real_monitor_dimensions, and could not be set in Xserver config. But I found its set in xdm/Xservers, I saw that x11 R device and ps dump from them are dependent on it. Thank you! -- Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Two Y-axises and One X-axis
On Fri, Nov 07, 2003 at 11:12:06AM -0600, umeno wrote: I would like to know if anyone knows how to draw a plot with two Y-axises and one X-axis? When you have two sets of y values that do not have the same scale, but correspond to the same x value, I would like to plot them on one graph. x11() plot(1:10) op - par(new = TRUE) plot(101:110, axes = FALSE, xlab = , ylab = , ylim = c(90, 120)) axis(4) par(op) -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] lang2(...) with two and more arguments
On Tue, Nov 03, 2003 at 17:06:37 +0100, you wrote: REAL(x)[0] = 10; REAL(y)[0] = 20; SETCADR(R_fcall, x); SETCADR(R_fcall, y); ... .Call(f, c, new.env()) returns `.Primitive(c)(20)' Hmmm. This is definitely not right: SETCADR(R_fcall, x); SETCADR(R_fcall, y); sets the same location first to x, and then to y. I suspect you need SETCADDR(R_fcall, y); but no guarantees... This returns message `bad value'. Ok! the question is: How can I create a call with, say, 10 arguments? I mean C code, of course :) Thanks. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] lang2(...) with two and more arguments
Dear R-help, how could I create an R call in C code using lang2 with 2 and more arguments? I tried this code: SEXP f(SEXP fn, SEXP rho) { SEXP R_fcall, x, y; PROTECT(R_fcall = lang2(fn, R_NilValue)); PROTECT(x = allocVector(REALSXP, 1)); PROTECT(y = allocVector(REALSXP, 1)); REAL(x)[0] = 10; REAL(y)[0] = 20; SETCADR(R_fcall, x); SETCADR(R_fcall, y); UNPROTECT(3); return R_fcall; } .Call(f, c, new.env()) returns `.Primitive(c)(20)', but not `.Primitive(c)(10, 20)', as I expected. How can I recieve the disired result? Thank you very much. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] evaluating expression within nls()
Dear R experts, I'd like to fit data with weighted function fcn(data, p1, p2). At first I used the standard form: nls(~ fcn(data, p1, p2), start = list(p1 = p01, p2 = p02), data = data) Then, I decided to change fcn() that it would be able to accept expression as an additional parameter, nls(~ fcn(data, expr, p1, p2), ...) # ('expr' is defined just before 'nls' calling) Error in eval(expr, envir, enclos) : Object expr not found Yes, in help(nls) is pointed, that Arguments: data: an optional data frame in which to evaluate the variables in `formula' But, I'd like 'nls' to see my expression 'expr'... :-/ How can I do that? Thank you! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] evaluating expression within nls()
On Wed, Oct 29, 2003 at 06:54:05PM +0300, Timur Elzhov wrote: Yes, in help(nls) is pointed, that Arguments: data: an optional data frame in which to evaluate the variables in `formula' But, I'd like 'nls' to see my expression 'expr'... :-/ How can I do that? Sorry, I was mistaken :) The bug was in the another my function. -- WBR __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] R graphics + non-R langs
Hello, dear R experts! One of the first reasons I began to use R, was its beautiful plotting capabilities. I found them very nice and simple. But at the last time I consider another languages (Perl, Python) for coding my scientific applications. So for now, in order to plot graphics I have to write data to the disk, launch R separately, and run R script just to plot my data. I gave a glance at the other scientific plotting libraries (plplot, pgplot, dislin) - all of them support API of many languages. The question is: what about R graphics? Is it so hard to bind it with any non-R languages? Thank you! -- WBR, Timur V. Elzhov __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] 'format' problem
Dear R experts, format(12345678, digits = 2) gives [1] 1.2e+07 while format(1234567, digits = 2) gives [1] 1234567 but I'd like the last number to be represented as 1.2e+06 string too. Where am I wrong? Thanks, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Second Y axis
On Wed, Jul 02, 2003 at 04:05:13PM -0400, Depinay, Jean-marc (NIH/FIC) wrote: I would like to add a second graph on the right y axis. Is it a way to do so with R? plot(...)# you normally plot 1st graph par(new = TRUE) # 2nd graph won't clean the 1st plot(..., axes = FALSE, xlab = , ylab = ) # plotting 2ng graph axis(4) -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] if else statements in R
On Mon, Jun 30, 2003 at 11:21:52AM -0400, Michael Rennie wrote: W- function(w) { if (comp[i,1]=1) W[i]-Wo else == is comparison operator, but = is assignment one. This code also doesn't work: x - 0 if (x = 1) Error: syntax error But this works: if (x == 1) + Chack also help(==), help(=) -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] saving plots
On Mon, Jun 23, 2003 at 11:07:15AM -0400, Matt Oliver wrote: Hi all, I am have an R script that makes many plots, and I would like to string them into a movie file. To do that I have to save all of my plots as jpegs or gifs. I don't want to go through all of my plots and save them by hand though. Is there a way to automate saving the plots as a gif or a jpeg so I can string them into a movie? ?dev.copy is probably that you want. dev.copy(device = jpeg) dev.off() -- WBR, Timur __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] persp(), par() and axis()
Dear R experts, On explanation of persp() parameters the last item is: ...: additional graphical parameters (see `par'). However, setting the `tcl' parameter has no any effect. I guess that axes are added to persp() in somewhat freakish way, and have nothing in common with axis() function. I found the very useful trans3d() function in persp() help page, and I'd like to use it with persp() + axis(), but I didn't find how to draw axis() in arbitrary place direction :( So, I want to customize axes in persp(). Could anybody help me solve this problem? Thanks a lot! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] persp colors
Dear R experts! I use image() persp() functions for color plotting z(x,y)-type graphics. In image() colors correspond to z-values, that's what I want. OTOH, in persp() the col option means: col: the color(s) of the surface facets. Transparent colours are ignored. This is recycled to the (nx-1)(ny-1) facets. but I'd like to persp()' colors behave like in image() function! Could you help me to solve this problem? Thank you very much. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] persp colors
On Sun, Jun 01, 2003 at 06:53:55PM +0200, Uwe Ligges wrote: but I'd like to persp()' colors behave like in image() function! That's not easy, because you have to redefine x, y and z values. Simple example: x - y - 1:2 z - matrix(1:4, 2) image(x, y, z)# OK, quite nice but persp(x, y, z) has only one facet. So the only way is to calculate the 9 values for x, y, and z to get the corners for the 4 facets in it. That's easy for x and y, but can be impossible for z... OK, thank you for answer! But, I saw that other mathematic frameworks (CERN ROOT for instance) can plot 3D surfaces with colors corresponding to z-value. Is there way to do this in R (with another functions/packages)? It's not necessary to use _one_ color per facet, yes?.. :) -- WBR, Timur. __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Error analysis
Dear R experts, I fitted data (length == m) with an external library (that's a non-linear problem), and, I've got the final parameter vector (length == n) and Jacobian matrix (dim == c(m, n)). Now, I want to analyse the standard errors of the parameters correctly. How can I do it? Where can I read about it else? Thanks! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] `UNPROTECT' and `return'
Dear R experts, In all R functions written in C one must unprotect result before returning them: { ... UNPROTECT(1) /* unprotecting `ans' */ return ans; } Why does one shure that memory occupied by `ans' won't be used by R immediately after unprotecting? Ok, is the next construction also absolutely safe? { ... UNPROTECT(1) /* unprotecting `ans' */ PROTECT( val = ans ) ... } Thanks a lot! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Too many e-mails
On Mon, Jan 20, 2003 at 02:50:36PM -, Jonathan Williams wrote: Oh dear - I joined the R help mailing list last week, in order to ask a specific question. I did not realise that I would start to receive all e-mails to and from the mailing list. Is there a way of letting me receive only the answers to my own questions? If not, then can you remove me from the mailing list? Read http://www.r-project.org/mail.html to unsubscribe. Then, you'll able send you question to [EMAIL PROTECTED], and if one knows the answer, he will reply it to _you_, and copy to R-help list as well. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Arguments of R- and C-side of internal functions
Dear R experts, I looked at the body of, say, `optim' function and found the call to the `.Internal', C optim function. It looks like this: .Internal(optim(par, fn1, gr1, method, con, lower, upper)) On the other hand, the C prototype of optim is: SEXP do_optim(SEXP call, SEXP op, SEXP args, SEXP rho); So, I guess that all the list of parameters passing in R are assigned to `args', right? First, how is that implemented? I looked at the `.Call()' - as I understand, it requires for C-side the same number of parametrs (minus the function name to be called); and `.External()' - it wants the single list. Second, who pass the other, `call', `op' and `rho' parameters to `do_optim() ?' Thank you! -- WBR, Timur __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Calling R function from within C code
Dear R experts, I'd like to call R function from within C code. I looked through the 'R exts' manual, found examples with lang2(R_fcall, list), and tried it, but it seemed to create the call, which can accept only a single argument of 'list' type, when I need to create the call of R functions with arbitrary numbers of arguments. How can I do it? Thanks a lot. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Calling R function from within C code
On Thu, Jan 16, 2003 at 03:22:42PM +, [EMAIL PROTECTED] wrote: That way. It's a pairlist of arguments. As that manual says Thank you, Mr. Ripley! But, it was interesing for me for a long - what is a principal difference between 'pairlist' and a general list? Why to access pairlist elements I need to use the strange macro like CAR(CDR(x)), and cannot do it by VECTOR_ELT(x, i) ? Thank you very much again! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
Re: [R] Calling R function from within C code
On Thu, Jan 16, 2003 at 09:50:34PM +0300, Timur Elzhov wrote: .Call(foo, rnorm, 1, 2, new.env()) function (x, y) match.call()(x = list(1, 2)) Oh, I'm mistaken. The `.Call(foo, f, 1, 2, new.env())' is the right string, of course. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] Evaluating expressions from within C code
Dear R experts! I want to evaluate expressions from within C code. For instance, I want this code: /* -- C code -- == */ #include R.h #include Rinternals.h SEXP foo(SEXP expr, SEXP rho) { SEXP x; PROTECT(x = allocVector(REALSXP, 1)); REAL(x)[0] = 1; UNPROTECT(1); return eval(expr, rho); } /* */ .Call(foo, quote(x + 1), new.env()) to return 1 + 1 == 2. But it certainly does not work: .Call(foo, quote(x + 1), new.env()) Error: Object x not found and if I define x in R, it works: x - 1 .Call(foo, quote(x + 1), new.env()) [1] 2 So, is there a way to solve my problem, namely to find and evaluate expressions that appears in C code? Thank you very much. -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
[R] handling objects plotted on x11 device
Dear R masters! Is it possible to handle objects have already been plotted on x11 device? For example, I wrote the text on the wrong place. Can I remove it, or I have to re-draw all the canvas, again? Thank you! -- WBR, Timur. __ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help