[R] random point in a circle centred in a geographical position

2006-10-07 Thread Albert Picado
Dear List members I am trying to find a way to generate a random point in a circle centred in a geographical location. So far I have used the following formula (see code below): random_x = original_x + radius*cos(angle) random_y = original_y + radius*sin(angle) where radius is a random number

Re: [R] random point in a circle centred in a geographical posit

2006-10-07 Thread Ted Harding
Hi Albert On 07-Oct-06 Albert Picado wrote: Dear List members I am trying to find a way to generate a random point in a circle centred in a geographical location. So far I have used the following formula (see code below): random_x = original_x + radius*cos(angle) random_y = original_y +

[R] Sweave, latex Warning

2006-10-07 Thread Göran Broström
When I am using Sweave to produce reports I get a strange Warning from latex: LaTeX Warning: You have requested package `/usr/local/lib/R/share/texmf/Sweave', but the package provides `Sweave'. It seems to be completely harmless, but I wonder if it is a symptom of installation

Re: [R] Sweave, latex Warning

2006-10-07 Thread Gregor Gorjanc
Göran Broström goran.brostrom at gmail.com writes: When I am using Sweave to produce reports I get a strange Warning from latex: LaTeX Warning: You have requested package `/usr/local/lib/R/share/texmf/Sweave' but the package provides `Sweave'. It seems to be completely

[R] (no subject)

2006-10-07 Thread Roger Bivand
On Sat, 7 Oct 2006 [EMAIL PROTECTED] wrote: Hi Albert On 07-Oct-06 Albert Picado wrote: Dear List members I am trying to find a way to generate a random point in a circle centred in a geographical location. So far I have used the following formula (see code below): random_x =

[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

Re: [R] [R-pkg] New packages pmg, gWidgets, gWidgetsRGtk2

2006-10-07 Thread verzani
I answered Gabor off line, but realize that this may cause some others confusion. The RGtk2 package requires the GTK libraries to be installed first. This varies from system to system. Under Windows it consists of downloading some files from sourceforget (see below). After which RGtk2 installs

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

2006-10-07 Thread Gabor Grothendieck
Try n - 1 f - if (n == 1) sin else cos f(pi) On 10/7/06, Alberto Vieira Ferreira Monteiro [EMAIL PROTECTED] wrote: 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.

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

2006-10-07 Thread Peter Dalgaard
Alberto Vieira Ferreira Monteiro [EMAIL PROTECTED] writes: Why this kind of assignment does not work? n - 1 f - ifelse(n == 1, sin, cos) f(pi) It's not supposed to. 'ifelse' returns a value with the same shape as 'test' which is filled with elements selected from either

Re: [R] Sweave, latex Warning

2006-10-07 Thread Göran Broström
On 10/7/06, Gregor Gorjanc [EMAIL PROTECTED] wrote: Göran Broström goran.brostrom at gmail.com writes: When I am using Sweave to produce reports I get a strange Warning from latex: LaTeX Warning: You have requested package `/usr/local/lib/R/share/texmf/Sweave' but

Re: [R] Estimate in Wilcox_test vs wilcox.exact

2006-10-07 Thread Dieter Menne
Jue.Wang2 at sanofi-aventis.com writes: Does any one know why wilcox.exact sometimes doesn't agree with wilcox_test on the estimate of the difference of medians in two levels ? Example removed See: http://finzi.psych.upenn.edu/R/Rhelp02a/archive/85893.html Dieter

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

2006-10-07 Thread Rolf Turner
Peter Dalgaard writes: Alberto Vieira Ferreira Monteiro [EMAIL PROTECTED] writes: Why this kind of assignment does not work? n - 1 f - ifelse(n == 1, sin, cos) f(pi) It's not supposed to. 'ifelse' returns a value with the same shape as 'test' which is filled

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

2006-10-07 Thread Gabor Grothendieck
I have noticed that dispatch on functions seems not to work in another case too. We define + on functions (I have ignored the niceties of sorting out the environments as we don't really need it for this example) but when we try to use it, it fails even though in the second example if we run it

Re: [R] Row comparisons to a new matrix?

2006-10-07 Thread Atte Tenkanen
---BeginMessage--- Thanks Gabor, Your version is handy to use, because you can change the function as you like. However it isn't any faster and if you know some way to make the result matrix more quickly, I'm interested to learn it. My test material (musical improvisations) consists of samples

Re: [R] Row comparisons to a new matrix?

2006-10-07 Thread Atte Tenkanen
Thanks Gabor, Your version is handy to use, because you can change the function as you like. However it isn't any faster and if you know some way to make the result matrix more quickly, I'm interested to learn it. My test material (musical improvisations) consists of samples with 2x2

[R] error compiling packages with r-2.4.0 on ppc mac osx 10.4.7

2006-10-07 Thread Strand, Allan Edgar
Hi All, As the subject says, I am working on a powerPC (G4) mac with OSX version 10.4.7. I upgraded from r-2.2.1 to r-2.4.0 today using the universal binary dmg file downloaded from CRAN. This is the complete, not mini binary. The interactive environment works great, but I am having

Re: [R] [R-pkgs] New versions of Matrix and lme4 packages for R-2.4.0

2006-10-07 Thread Patrick Connolly
On Tue, 03-Oct-2006 at 09:56AM -0500, Douglas Bates wrote: | Versions 0.9975-1 of the Matrix and lme4 packages will soon be available on | CRAN for use with R version 2.4.0 or later. How quickly things change!! When I got to look at CRAN, the latest versions were 0.9975-1 of lme4 and 0.9975-2

[R] Installing Lindsey's packages

2006-10-07 Thread Michael Kubovy
Dear r-helpers, I downloaded http://popgen.unimaas.nl/~jlindsey/rcode/rmutil.tar (it was originally .tgz, but got unzipped by my browser). Can anyone give me detailed instructions on installing this and Lindsey's other packages on R version 2.4.0 (2006-10-03)---(powerpc- apple-darwin8.7.0,

Re: [R] Sum of Bernoullis with varying probabilities

2006-10-07 Thread Ted Harding
Hi again. I had suspected that doing the calculation by a convolution method might be both straightforward and efficient in R. I've now located convolve() (in 'base'!!), and have a solution using this function. Details below. Original statement of problem, and method originally proposed, repeated

[R] merge and polylist

2006-10-07 Thread Mihai Nica
Greetings: I would like to kindly ask for a little help. The rough code is: # dat=data.frame(read.delim(file=all.txt, header = TRUE, sep = \t, quote=\, dec=.,na.strings = NA)) nc=read.shape(astae.shp, dbf.data=TRUE, verbose=TRUE)

[R] xlsReadWrite version 1.1.1 available

2006-10-07 Thread Hans-Peter
An updated version 1.1.1 of xlsReadWrite has been submitted to cran. Currently the cran version is still 1.0, but you can download the updated version already here: http://treetron.googlepages.com. xlsReadWrite is a package which allows you to natively read and write Excelfiles (windows only).

Re: [R] unexpected behavior of boxplot(x, notch=TRUE, log=y)

2006-10-07 Thread Ben Bolker
bogdan romocea br44114 at gmail.com writes: A function I've been using for a while returned a surprising [to me, given the data] error recently: Error in plot.window(xlim, ylim, log, asp, ...) : Logarithmic axis must have positive limits After some digging I realized what was

[R] can lm() automatically take in the independent variables without knowing the names in advance

2006-10-07 Thread HelponR
Hello! I am trying to use lm to do a simple regression but on a batch of different files. Each file has different column names. I know the first column is the dependent variable and all the rest are explanatory variables. The column names are in the first line of the file. But it seems lm()

Re: [R] Sum of Bernoullis with varying probabilities

2006-10-07 Thread Gabor Grothendieck
One can get a one-line solution by taking the product of the FFTs. For example, let p - 1:4/8 be the probabilities. Then the solution is: fft(exp(rowSums(log(mvfft(t(cbind(1-p,p,0,0,0)), inverse = TRUE)/5 On 10/7/06, Ted Harding [EMAIL PROTECTED] wrote: Hi again. I had suspected that

Re: [R] can lm() automatically take in the independent variableswithout knowing the names in advance

2006-10-07 Thread Leeds, Mark \(IED\)
someone may know how to do what you asked but a get around is to not read the header in the file and assign your own variable names to each column. This way you have control and you don't worry about doing anything dynamically. This is pretty easy if you are using read.table and probably also

Re: [R] can lm() automatically take in the independent variables without knowing the names in advance

2006-10-07 Thread Gabor Grothendieck
Try this: run.lm - function(DF, response = names(DF)[1], fo = y~.) { fo[[2]] - as.name(response) eval(substitute(lm(fo, DF))) } # test run.lm(iris) run.lm(iris, Sepal.Width) Another possibility is to rename the first column: On 10/7/06, HelponR [EMAIL PROTECTED] wrote:

Re: [R] can lm() automatically take in the independent variables without knowing the names in advance

2006-10-07 Thread HelponR
This works beautifully! You know I did not know how many columns in advance either. So this method is very good. Many thanks! On 10/7/06, Gabor Grothendieck [EMAIL PROTECTED] wrote: Try this: run.lm - function(DF, response = names(DF)[1], fo = y~.) { fo[[2]] - as.name(response)

[R] Select range of dates

2006-10-07 Thread Ian Broom
Hello, This is likely fairly silly question, and I apologize to whomever takes the time to respond. I am a relatively new user of R, on Windows XP, version 2.3.1. Say I have a data table that looks like the following: x Date Location Amount Blue Green 1 01/01/2001 Central1817

Re: [R] Select range of dates

2006-10-07 Thread Gabor Grothendieck
Here are three alternative ways to get the fiscal year as a numeric value assuming: dd - as.Date(x$Date,%d/%m/%Y) # add one to year if month is past March as.numeric(format(dd, %Y)) + (format(dd, %m) 03) # same but using POSIXlt # (Even though there are no time zones involved I have seen #