Re: [R] Derivative of a Function Expression

2007-09-03 Thread Alberto Vieira Ferreira Monteiro
Gabor Grothendieck wrote: Actually in thinking about this its pretty easy to do it without Ryacas too: Df - f body(Df) - deriv(body(f), x) Df This is weird. f - function(x) { x^2 + 2*x+1 } Df - f body(Df) - deriv(body(f), x) # error Also: f - function(x) x^2 + 2 * x + 1 Df - f body(Df)

[R] Windows source in Linux

2007-06-01 Thread Alberto Vieira Ferreira Monteiro
I have a windows source file.r, with the default charset of windows. I can't use it in Linux as source(file.r), because Linux's default is Unicode. How can I read it? Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list

Re: [R] Windows source in Linux

2007-06-01 Thread Alberto Vieira Ferreira Monteiro
Benilton Carvalho wrote: iconv on your linux box should do the work. I have a windows source file.r, with the default charset of windows. I can't use it in Linux as source(file.r), because Linux's default is Unicode. How can I read it? Soon after I posted, I found out how to do it.

[R] Running an R script without running R

2007-05-20 Thread Alberto Vieira Ferreira Monteiro
Is there any way to run an R script without running R? As an example, suppose I have a tcl/tk interface that asks for a number (in a GUI) and displays its factorial. Is there a way to invoke this script without invoking R? I'm using R 2.4.1 in GNU/Linux Fedora Core 4. Alberto Monteiro

Re: [R] A function for raising a matrix to a power?

2007-05-07 Thread Alberto Vieira Ferreira Monteiro
Michael Dewey wrote: I may be revealing my ignorance here, but is MatrixExp in the msm package (available from CRAN) not relevant here? Never heard about it. Searching with help.search(matrix) didn't show any function that might be used as Matrix^n. Alberto Monteiro

Re: [R] A function for raising a matrix to a power?

2007-05-07 Thread Alberto Vieira Ferreira Monteiro
Paul Gilbert wrote: I am getting a bit rusty on some of these things, but I seem to recall that there is a numerical advantage (speed and/or accuracy?) to diagonalizing: (...) I think this also works for non-integer, negative, large, and complex This is diverging into mathematics, maybe

Re: [R] A function for raising a matrix to a power?

2007-05-06 Thread Alberto Vieira Ferreira Monteiro
Ron E. VanNimwegen wrote: I was looking for a similar operator, because R uses scalar products when raising a matrix to a power with ^. There might be something more elegant, but this little loop function will do what you need for a matrix mat raised to a power pow: mp - function(mat,pow){

Re: [R] Help with map

2007-05-04 Thread Alberto Vieira Ferreira Monteiro
[for those that worry about these things, this _is_ a homework assignment. However, it's not an R homework, it's a Geography and History homework... and I want to use R to create a pretty map] Roger Bivand wrote: Is there any way to associate one color to each country? Try: map_poly_obj -

[R] Off topic? Geographic data

2007-05-03 Thread Alberto Vieira Ferreira Monteiro
Sorry if this is off-topic, but since there are so many data sets in R, I wonder if there is any data set with Geographic data, like (latitude,longitude) lists of the contour of the continents and countries. Alberto Monteiro __

Re: [R] package for Matlab

2007-04-05 Thread Alberto Vieira Ferreira Monteiro
Petr PIKAL wrote: You probably could get quicker answer trying to use some search posibilities provided by CRAN. OTOH, if we try to google for R, we get 1.880.000.000 hits :-) Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list

Re: [R] faster computation of cumulative multinomial distribution

2007-03-30 Thread Alberto Vieira Ferreira Monteiro
Theo Borm wrote: Think of a sort of power roulette, played with 58 balls simultaneously, with a wheel containing 36 red/black slots of unequal size, and 1 green slot. I need to calculate the probability that each of the 36 red/black slots contains at least one ball. Ah, now we come to a more

Re: [R] sampling from the unoform distrubuton over a convex hull

2007-03-24 Thread Alberto Vieira Ferreira Monteiro
Duncan Murdoch wrote: Suggestion: Find a rectangular region containing the hull, and sample uniformly there. Accept points that don't expand the hull of the original points. This is a feasible solution only in lower dimensions; the area of the convex hull can become exponentially small

Re: [R] XML - can create but can't save

2007-03-20 Thread Alberto Vieira Ferreira Monteiro
Duncan Temple Lang wrote: Just for the record, the method has been added for that particular type of tree. So the original saveXML(tt, file = test.xml) will work. Ah, the wonders of free software... I didn't have to wait a single day to have the bug fixed :-) Alberto Monteiro

Re: [R] What is a expression good for?

2007-02-28 Thread Alberto Vieira Ferreira Monteiro
Bert Gunter wrote: An expression object is the output of parse(), and so is R's representation of a parsed expression. It is a type of list -- a parse tree for the expression. This means that you can actually find the sorts of things you mention by taking it apart as a list: ex - parse(text

Re: [R] Random Integers

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
Charles Annis, P.E. wrote: rpois(n, lambda) ... will do it. But you should tell us something about how you want your numbers to be distributed, since rpois() produces integers having a Poisson distribution. nitpick rpois does not generate random _integers_, it generates random _natural

Re: [R] Double-banger function names: preferences and suggestions

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
hadley wickham wrote: What do you prefer/recommend for double-banger function names: 1 scale.colour 2 scale_colour 3 scaleColour 1 is more R-like, but conflicts with S3. 2 is a modern version of number 1, but not many packages use it. Number 3 is more java-like. (I like number 2

[R] RSPython

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
Any hints on how to make RSPython work? I downloaded and installed it, but I can't use it neither from python nor from R! Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting

Re: [R] RSPython

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
Duncan Temple Lang wrote: Well, we'll need to know in what ways it doesn't work and what operating system you are using, etc. In python: import RS Traceback (most recent call last): File stdin, line 1, in ? ImportError: No module named RS In R: library(RSPython) Erro em

[R] RPy and the evil underscore

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
I seems like I will join two threads :-) Ok, RPy was installed (in Fedora Core 4, yum -y install rpy), and it is running. However, I have a doubt, and the (meagre) documentation doesn't seem to address it. In python, when I do this: import rpy rpy.r.setwd(/mypath) rpy.r.source(myfile.r)

[R] random uniform sample of points on an ellipsoid (e.g. WG

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
I guess this sample is required for some practical application, say a simulation for something done over the Earth. Then, I also guess that the sample does not have to be _absolutely_ exact, but a reasonable approximation can do it. And the ellipsoid is a rotation ellipsoid. This is my

Re: [R] newbie question

2006-10-21 Thread Alberto Vieira Ferreira Monteiro
Larry White wrote: Sorry - this must be obvious, Yes, it is :-) I want to be able to filter data in a dataframe before analyzing it. For example, I'd like to plot(a,b) but only include values where b 1000. If a and b are vectors, then b 1000 is another vector of logical values. You can

Re: [R] Function that operates on functions: it's ok, but the display isn't

2006-10-10 Thread Alberto Vieira Ferreira Monteiro
Deepayan Sarkar wrote: # f1 is a function that takes one function # as argument, and returns another function f1 - function(f) function(x) f(x+1) - f(x) # h(x) is g(x+1) - g(x) or 2x + 1 h - f1(g) h function(x) f(x+1)-f(x) environment: 0264BE84 Presumably, 'f' takes the value 'g' in

[R] ifelse(logical, function1, function2) does not work

2006-10-07 Thread Alberto Vieira Ferreira Monteiro
Why this kind of assignment does not work? n - 1 f - ifelse(n == 1, sin, cos) f(pi) this must be rewritten as: n - 1 f - cos if (n == 1) f - sin f(pi) [oops. 1.224606e-16 instead of zero. Damn floating point errors :-/] Alberto Monteiro

[R] if (NULL) is error?

2006-10-01 Thread Alberto Vieira Ferreira Monteiro
Why this is not valid? test - NULL if (test) test Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide

Re: [R] Simple graphics

2006-10-01 Thread Alberto Vieira Ferreira Monteiro
Jim Holtman wrote: Is this what you want? You have to reset the margins: png(file.png, width=200, height=200) par(mar=c(0,0,0,0)) # reset margins plot(0, xlim=c(0,200), ylim=c(0,200), type='n') polygon(c(50, 50, 150, 150), c(50, 150, 150, 50)) dev.off() Yes and no. This sort-of does

[R] Simple graphics

2006-09-29 Thread Alberto Vieira Ferreira Monteiro
Is there any way that I can do something like this: png(file.png, width=200, height=200) polygon(c(50, 50, 150, 150), c(50, 150, 150, 50)) dev.off() and then have a png file with a 100 x 100 pixels rectangle in the middle of it? It seems that when I call plot, it redefines the image