Re: [R] arima crashes too

2009-10-23 Thread Alberto Monteiro
Barry Rowlingson wrote: However, arima crashes for this: arima(c(1.71, 1.78, 1.95, 1.59, 2.13), order=c(1,0,0)) I'm not getting what I'd call 'crashes' with your arma or arima examples- I get an error message and a warning: arma(c(2.01, 2.22, 2.09, 2.17, 2.42), order=c(1,0)) Error in

Re: [R] arima crashes too

2009-10-23 Thread Alberto Monteiro
Barry Rowlingson wrote: If you're doing anything in a loop that has the potential to fail because of singularities or other conditions when your model can't be fitted, you need to stick what you are doing in a 'try' clause. This lets you trap errors and do something with them. Plenty

[R] arma crashing

2009-10-22 Thread Alberto Monteiro
Function arma is crashing in some (pathological, but crashing is never good) cases. For example: library(tseries) arma(c(2.01, 2.22, 2.09, 2.17, 2.42), order=c(1,0)) I came to that pathological series while doing test cases; probably there are crashing cases with longer series. Alberto

[R] arima crashes too

2009-10-22 Thread Alberto Monteiro
Another pathological test. arima does not crash for that series that crashes arma: arima(c(2.01, 2.22, 2.09, 2.17, 2.42), order=c(1,0,0)) However, arima crashes for this: arima(c(1.71, 1.78, 1.95, 1.59, 2.13), order=c(1,0,0)) arima seems pretty consistent in its crashing behaviour, since

Re: [R] Simple extraction of level,x,y from contourLines()

2009-10-22 Thread Alberto Monteiro
for an expression which will return the vector c(C.W[[1]]$level,C.W[[2]]$level,...,C.W[[28]]$level) H... Did you try this? # reproducible example C.W - list(list(level = 1, x = 2), list(level = 2, y = 3), list(level = 10, z = 4)) sapply(C.W, function(x) x$level) Alberto Monteiro

[R] Confidence intervals and p-values of ARMAX model

2009-10-16 Thread Alberto Monteiro
tries to get this information from Wikipedia, the entries in articles Autoregressive model, Autoregressive moving average model, and Autoregressive integrated moving average that mention R were written by me - so there's no point in repeating them (but corrections are welcome!) :-) Alberto

Re: [R] using a custom color sequence for image()

2009-10-16 Thread Alberto Monteiro
, seq(0, 1, length=256), 0)) Explanation: rgb(0, seq(0, 1, length=256), 0) creates a vector of colours that begin with black = #0 and ends up with green = #00FF00. Parameter nlevels = 256 forces the image to use all colours. Alberto Monteiro __ R

Re: [R] Cannot calculate mean() for double vector

2009-10-16 Thread Alberto Monteiro
includes one (or more) NA (and not N/A) in it. Test: if (any(is.na(x_ema))) cat(Oops! NAs in x_ema\n) If you want to get which of them are na: which(is.na(x_ema)) Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r

Re: [R] How can I run a function to a piece of text?

2009-10-16 Thread Alberto Monteiro
- but still as a string mean.string - paste(mean(, script, ), sep = ) # Step 2: compute it eval(parse(text = mean.string)) Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

[R] ANOVA and T-test with means and SEs as imput

2008-10-29 Thread José Alberto Monteiro
Dear friends I am analysing the leaf expansion of a grass species and am interested in the speed of expansion. I produced exponential models for each of the treatments and got the equation for leaf size in function of time. I want to compare the coeficients that gives the initial inclination of

[R] plot inside graphic area

2008-09-30 Thread José Alberto Monteiro
I am trying to plot a small graphic inside the graphic area of a bigger graphic. Does anybody know the commend for that? Thanks a lot! -- MSc José Alberto F. Monteiro Botanisches Institut Universität Basel السلام عليكم [[alternative HTML version deleted]]

[R] arma: what is the meaning of Pr(|t|)?

2008-08-20 Thread Alberto Monteiro
of the series x is deterministic, and two degrees are lost in the estimation of ar1 and intercept) What am I misunderstanding? BTW, a similar example: x - 1:10 y - sin(x) reg - lm(y ~ x) summary(reg) will give a t-value for 'x' = 0.704 with P(|t|) = 0.501, which is 2 * (1 - pt(0.704, df=8)) Alberto

Re: [R] Using metric units in plots

2008-06-20 Thread Alberto Monteiro
metric parameters in every function. Maybe Humanity must lose a few more people in airplane crashes or nuclear plant meltdowns before we ban those unscientific units from use. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch

[R] Low-discrepancy sequences

2008-06-18 Thread Alberto Monteiro
Is there any way to _test_ if a given sequence is a low-discrepancy sequence? Or, equivalently, is there any way to measure the discrepancy of a sequence? WTIW, ... http://en.wikipedia.org/wiki/Low-discrepancy_sequence ... doesn't look like something implementation-friendly :-) Alberto

[R] Annoyance in as.numeric

2008-06-16 Thread Alberto Monteiro
Why does as.numeric convert matrices and arrays to vectors? as.numeric(matrix(c(1, 2, 3, 4), 2, 2)) [1] 1 2 3 4 I could only figure out ugly ways to bypass this, like: x - matrix(c(1, 2, 3, 4), 2, 2) array(as.numeric(x), dim = dim(x), dimnames = dimnames(x)) Alberto Monteiro

[R] A curious bug in read.xls

2008-06-10 Thread Alberto Monteiro
I found a curious bug in read.xls. I don't know if it's reproducible. It's like this: suppose I do a read.xls in a spreadsheet. A column begins with a number. Then, any strings below it will be rendered as NA. If the column begins with a string, then it will be rendered correctly. Alberto

[R] Plot matrix as many lines

2008-06-06 Thread Alberto Monteiro
Suppose that I have a matrix like: m - rbind(c(1,2,3,4), c(2,3,2,1)) Is there any way to efficiently plot the _lines_ as if I was doing: plot(m[1,], type=l) points(m[2,], type=l, col=red) (of course, in the real world there much more than just 2 lines and 4 columns...) Alberto Monteiro

[R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Alberto Monteiro
(that is _not_ a matrix) and the pasting of the lines of matrix.out? Alberto Monteiro PS: this is not a homework, this is evangelism to a Visual Basic programmer :-) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Alberto Monteiro
(file.in) returns an error: Erro em scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : linha 1 não tinha 1362 elementos which means line 1 does not have 1362 elements (whatever that means!) Alberto Monteiro __ R-help@r-project.org

Re: [R] Hyper-elegant code to get a text file, transpose it, and write it

2008-06-05 Thread Alberto Monteiro
0.8746 I didn't find in the documentation of write.table a way to remove those quotes, because qmethod is either escape or double :-( Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

[R] van der Corput sequences

2008-05-23 Thread Alberto Monteiro
, 0.8, 0.9, 0.01, 0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81, 0.91, 0.02, 0.12, 0.22, 0.32, … Is there any R function that generates those sequences? Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

[R] Question about Runuran (Triangular Distribution)

2008-05-23 Thread Alberto Monteiro
The Runuran package includes a simulation for the Triangular Distribution, urtriang. But I didn't find an analogue of the q* functions (rnorm - qnorm, runif - qunif), that would invert the CDF (?uqtriang). Are there any such functions? Alberto Monteiro

[R] ARCH model

2008-05-13 Thread Alberto Monteiro
tseries, but didn't understant how the output from its summary relate to the above quantities. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org

[R] How do I write a power of matrices?? [was: How do I write a sum of matrixes??]

2008-05-07 Thread Alberto Monteiro
is a _very_ big number. Alberto Monteiro __ R-help@r-project.org 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 commented, minimal, self-contained

Re: [R] How do I write a sum of matrixes??

2008-05-06 Thread Alberto Monteiro
for _diagonalizable_ matrices. It crashes, for example, in cases like: m - rbind(c(1,1,0), c(0,1,1), c(0,0,1)) m %^% 2 m %*% m Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] XML write?

2008-04-29 Thread Alberto Monteiro
Is there any function to write a XML structure, after it was read using xmlTreeParse? Ex: library(XML) x - xmlTreeParse(Irpf2008/aplicacao/dados/12345678901/12345678901.xml) # write it... Alberto Monteiro PS: please, brazilians, don't be offended by my foul language

Re: [R] XML write?

2008-04-29 Thread Alberto Monteiro
information not-xml related (and do what I want - again, sorry for the foul language). Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

[R] Function redefinition - not urgent, but I am curious

2008-04-18 Thread Alberto Monteiro
(x) # put something here 2 * f1(x) # probably put something else here too f2(10) # 22 f1 - function(x) x - 1 f2(10) # 22 - f1 inside f2 does not change Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help

Re: [R] = vs. ==?

2008-04-16 Thread Alberto Monteiro
://en.wikipedia.org/wiki/Aymara_language ...) uses this three value logic system (I think the computer jargon is trollean logic). Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] fuzzy merge

2008-04-09 Thread Alberto Monteiro
(new.dt2[i]$time2 - d1$time1) # get a vector of deltat's j.min - which.min(delta.t) if (delta.t[j.min] = 15 minutes) new.d2[i]$time1 - d1[j.min]$time1 } } # and now merge them d3-merge(d1, d2, by.x=time1, by.y=time1) Alberto Monteiro __ R

Re: [R] generate random numbers subject to constraints

2008-03-26 Thread Alberto Monteiro
distributed? Are they normal? Positive? If they can be anything, just generate X1, X2 and then compute X3, X4. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R

Re: [R] Inverse t-distribution

2008-03-24 Thread Alberto Monteiro
Bert Gunter wrote: Yes. And, amazingly, one can find out about it by typing help.search(t distribution) . Why don't you try it for yourself? Maybe because the obvious search is help.search(t) :-) Alberto Monteiro __ R-help@r-project.org

Re: [R] How to remove double for loop?

2008-03-19 Thread Alberto Monteiro
the explicit mention of f: Val - outer(0:n, 0:n, function(j,i) ifelse(j i, 0, u^j*d^(i-j))) (if u and d are positive integers, there might be a much faster way of filling Val, using matrix multiplication and rounding down) Alberto Monteiro __ R-help@r

Re: [R] How to remove double loop?

2008-03-19 Thread Alberto Monteiro
combined with the (j+1)-th term. So, you take a combination of js in the 1:i range and combine with js in the 2:(i+1) range... So: OVal[1:i, i] - a*((1-p)*OVal[1:i, i+1] + p*OVal[2:(i+1), i+1]) The outer loop (in i) probably can't be optimized. Alberto Monteiro

Re: [R] Specifying relative position of text in a plot

2008-03-12 Thread Alberto Monteiro
the y axis and 1/2 of the way up from the x axis? Thanks. See the help of par: ?par Namely: plot(rnorm(100), rnorm(100)) pu - par()$usr x - pu[1] * 0.5 + pu[2] * 0.5 y - pu[3] * 0.1 + pu[4] * 0.9 text(x, y, the quick brown fox jumps over a lazy dog) Alberto Monteiro

Re: [R] Jpeg and pixel

2008-03-11 Thread Alberto Monteiro
resolution. I saw that R can write in SVG format, using the RSVGTipsDevice library. I think SVG is the closest format to losslessness when printing. Of course, my ecological motivation would ban all formats that make printing easy, to save the environment by saving a few trees :-) Alberto Monteiro

[R] Weird feature in rimage

2008-03-10 Thread Alberto Monteiro
I just noticed a weird feature in rimage. It seems that, when reading an image, the line/colums are transposed. See this reproducible example. The final image should be black - but (as expected) not an absolute black (mean(z) is 0.015, sd(z) is 0.055 but max(z) is 1). Alberto Monteiro

[R] write in rimage package

2008-03-06 Thread Alberto Monteiro
borders around it. Alberto Monteiro __ R-help@r-project.org 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 commented, minimal, self-contained, reproducible

Re: [R] Excel export into R

2008-03-06 Thread Alberto Monteiro
to have a list of the planet names in roman, but x[,1] is not an array of strings, and cat(x[,1]) gives an error. --- end of fictional message --- FWIW, the reply to this message is: y - as.matrix(x) cat(y[,1]) Alberto Monteiro __ R-help@r-project.org

Re: [R] Interface or Select menu

2008-03-06 Thread Alberto Monteiro
have create this interface with other language. Thank you very much, and I hope that you understand my english. You mean like a GUI? There are many GUI packages in R, probably the simpler is the tcltk package. Alberto Monteiro __ R-help@r

Re: [R] R function to convert a number to text

2008-03-03 Thread Alberto Monteiro
=,collapse= )) } Be careful, the function does not handle empty fields: digits2text(10^6 + 10) [1] one million one thousand hundred thousand hundred ten Alberto Monteiro (today I am purely destructive) __ R-help@r-project.org mailing list https

Re: [R] Bug with curve?

2008-02-01 Thread Alberto Monteiro
- x g1(anything) will return (scalar) 0 g2(scalar) will return (scalar) 0, g2(vector) will return (vector) 0, g2(matrix) will return (matrix) 0. So, in your original problem, f and (first) g have different behaviours. Alberto Monteiro __ R-help@r

[R] list.files sorted by date

2008-01-21 Thread Alberto Monteiro
Is there any (list.files)-like function that sorts the files by (modification) date? Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting

Re: [R] R and Vista

2008-01-16 Thread Alberto Monteiro
_accented_ characters in filenames and paths. And they are not standard. So there may be a filename conflict here. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http

Re: [R] load tcltk

2008-01-10 Thread Alberto Monteiro
libraries exist, and check if there is some file protection. Probably there's a problem with: /usr/X11R6/lib/libX11.6.dylib Alberto Monteiro PS: is there any way to temporarily change the error messages from one language to another? When I get error messages in Portuguese it's a pain

Re: [R] 4 dimensional graphics

2008-01-10 Thread Alberto Monteiro
, converting height and value to colors? OTOH, if it's a function from R^3 to R: f: (lat, lon, h) - (value) then I guess the best way is to replace one dimension to time, and create animations. Alberto Monteiro __ R-help@r-project.org mailing list https

Re: [R] An R is slow-article

2008-01-09 Thread Alberto Monteiro
, and naively says that C is 50 times faster than R? Alberto Monteiro __ R-help@r-project.org 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 commented, minimal

[R] I need arguments pro-S-PLUS and against SAS...

2008-01-04 Thread Alberto Monteiro
I need arguments pro-S-PLUS and against SAS for a meeting I will have next week. S-Plus is (90 - 99)% compatible with R, so using S-Plus will make things much easier for everyone. But I can't use this argument. What other arguments could I use? Alberto Monteiro

[R] tukeyHSD

2008-01-03 Thread José Alberto Monteiro
Does anybody know how to deffine in the test tukeyHSD the pairs of comparison that you want to get? It is throw the lmat commnad, but I don't know the correct usage... Thanks a lot! José -- MSc José Alberto F. Monteiro Botanisches Institut Universität Basel السلام عليكم

Re: [R] Return Value of TCl/Tk window in R

2007-12-28 Thread Alberto Monteiro
are they used? Why don't you test it yourself? library(tcltk) x - tkmessageBox(title=,message=x,icon=question,type=okcancel) # press x or cancel x # Tcl ok or Tcl cancel To get back from this Tcl-thing to an R-string, use y - tclvalue(x) Alberto Monteiro

Re: [R] Communicating from one function to another

2007-11-26 Thread Alberto Monteiro
having to move it around in argument lists. In the C community, it would be called a global variable. Global variables in R are used with - instead of -. For example: x - 1 y - 1 f - function() { x - 2 y - 2 } f() will turn y to 2 but will not change x. Alberto Monteiro

Re: [R] Communicating from one function to another

2007-11-26 Thread Alberto Monteiro
really be called the user workspace. Got it. So, in this case: x - 1 f - function() { x - 2 g - function() { x - 3 } g() x } f() It's expected that f will return 3, but x would still be 1? Alberto Monteiro __ R-help@r-project.org mailing

[R] font formating

2007-11-15 Thread José Alberto Monteiro
I am tryindo to do a very simple thing but cannont find how to do it anywhere. I need to formap part of my title as subscript ans superscript. How can I do it? Thanks a lot in advance José -- MSc José Alberto F. Monteiro Botanisches Institut Universität Basel [[alternative HTML version

Re: [R] script fails because of library loading

2007-11-13 Thread Alberto Monteiro
and not to , like this: /usr/bin/R --quiet --slave /perl/outfiles/Rscript19785065.R /perl/outfiles/error19785065.txt 2 error.log Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

Re: [R] R as a programming language

2007-11-08 Thread Alberto Monteiro
a text in Latin-1 and removing the accented characters, or looping through a directory and renaming files with weird names, or creating a .wpl file with the mp3s. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] How to know created time of object in R?

2007-11-06 Thread Alberto Monteiro
could do it in C++, but I am illiterate in R++ oops S4 classes). Alberto Monteiro __ R-help@r-project.org 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] C++ and R interface

2007-11-06 Thread Alberto Monteiro
be done in C++, because C++ can call C functions. Just write the C++ code as: extern C int myfunction(int x1, int x2) { // write C++ code here return rval; } Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] tcltk: help with tkmenubutton

2007-10-19 Thread Alberto Monteiro
on Windows. Maybe that's the reason. Alberto Monteiro __ R-help@r-project.org 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 commented, minimal, self-contained

[R] tcltk: I guess I am starting to get it

2007-10-18 Thread Alberto Monteiro
loop - necessary in perl but not in R I tried to contact the author for permissions to translate, adapt and post the examples to the RWiki, but without success :-( Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo

Re: [R] Import from excel 2007

2007-10-16 Thread Alberto Monteiro
by people who only knows how to write Excel spreadshits, and you want to automate the reading and interpretation of such data so that you, as a R user, does not have to use Excel to convert the data to text. Alberto Monteiro __ R-help@r-project.org mailing

Re: [R] chi2

2007-10-10 Thread Alberto Monteiro
-like, with mean close to df, and standard deviation close to sqrt(df). Alberto Monteiro __ R-help@r-project.org 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] window (x,y) co-ordinates of datapoints

2007-10-10 Thread Alberto Monteiro
.cnn.com/TECH/space/9911/10/orbiter.03/ ;) That's why it should not be done _at all_, and all functions should have SI inputs (unless you are from Liberia, Myanmar, etc). Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman

Re: [R] window (x,y) co-ordinates of datapoints

2007-10-09 Thread Alberto Monteiro
Prof Brian Ripley wrote: Read ?par and the descriptiuon in 'An Introduction to R'. din, fin, mai, omi, pin and usr are relevant. Is there any hope that, instead of fin, din, pin, etc someday we will have fmm, dmm, pmm? Alberto Monteiro __ R

Re: [R] Dice simulation: Getting rep to re-evaluate sample()?

2007-10-08 Thread Alberto Monteiro
time? # get 10*100 random d6s x - sample(1:6, 10*100, replace=T) # transform into a 10 x 100 matrix y - matrix(x, 10, 100) # sum the cols z - colSums(y) Of course, you can combine these three lines into one. Alberto Monteiro __ R-help@r-project.org

Re: [R] Mouse Location on Plots

2007-10-08 Thread Alberto Monteiro
time ago, I noticed that programming that I do for fun is much more useful for my work in the long range than programming that I do for work; the algorithms and ideas that we put into gaming or hobbies are usually flawless and optimized :-) What are the R packages with games? Alberto Monteiro

[R] grep in filename

2007-10-04 Thread Alberto Monteiro
hungry) option. Alberto Monteiro __ R-help@r-project.org 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 commented, minimal, self-contained, reproducible

Re: [R] using sprintf with dates

2007-10-02 Thread Alberto Monteiro
), but it will just put some description of the function in the string. Also, the assignment in R is -, not =. Try: foot - function(){ str1 - format(Sys.Date(),%Y%m%d) sprintf(99%-4s%s,nm,str1) } Alberto Monteiro __ R-help@r-project.org mailing list https

[R] wordReport

2007-09-26 Thread Alberto Monteiro
); WordExit() will prompt for the Yes/No/Cancel prompt, and if I answer Yes, it opens the menu to Save As. (2) is there any way to write formulas in the evil Word formula format, but with input as decent latex-like format? Alberto Monteiro __ R-help@r

Re: [R] Calculate difference between dates in years

2007-09-24 Thread Alberto Monteiro
years and such. You know that there are _not_ 365.25 days in one year, don't you? floor(as.numeric(as.Date(2100-02-28) - as.Date(1900-02-28))/365.25) # 199, should be 200 A less extreme counter-example: floor(as.numeric(as.Date(2008-02-28) - as.Date(2007-02-28))/365.25) # 0, should be 1 Alberto

Re: [R] Evaluating args in a function

2007-09-12 Thread Alberto Monteiro
abbreviate function arguments... Thanks for the (accidental) help :-) Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html