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. > > Pl

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)

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

2009-10-22 Thread Alberto Monteiro
s at once! > > In other words, I'm looking 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(l

[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 crash

[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

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

2009-10-16 Thread Alberto Monteiro
The second way (and simpler) is to enclose the "mean" function into the script string, and then invoke the magic words: x<-c(1:10) script<-"x, trim = 0, na.rm = FALSE" # Step 1: convert script to the calling of mean - but still as a string mean.string <- paste("

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

2009-10-16 Thread Alberto Monteiro
of data type double, > it always returns N/A. > So, x_ema 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 ___

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

2009-10-16 Thread Alberto Monteiro
you want: image(x, y, z, nlevels=256, col=rgb(0, 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".

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

2009-10-16 Thread Alberto Monteiro
there's no point in repeating them (but corrections are welcome!) :-) 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 code.

[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 the

[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]] _

Re: [R] Simple estimate of a probability by simulation

2008-08-20 Thread Alberto Monteiro
pointwise product of vectors delta > 0 is a logical array with TRUE or FALSE sum(delta > 0) coerces TRUE to 1 and FALSE to 0 length(delta) is the length of delta (n) Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mail

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

2008-08-20 Thread Alberto Monteiro
e first value 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

[R] A doubt about "lm" and the meaning of its summary

2008-08-18 Thread Alberto Monteiro
27;Std. Error'] } # # Finally, let's analyse it # The distribution of (m.bar - m) / m.std.error should be # a Student's t with n - 2 degrees of freedom. # Is it? Let's test! # print(ks.test((m.bar - m) / m.std.error, rt(NN, n - 2))) ... and now it's not. What

Re: [R] Using metric units in plots

2008-06-20 Thread Alberto Monteiro
elieve it would be too hard to implement 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-

[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-friend

[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"),

[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 corr

[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 t

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

2008-06-05 Thread Alberto Monteiro
, like: "1/2/2003" "0.5638""0.6233""0.4559""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 __

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

2008-06-05 Thread Alberto Monteiro
E, col.names = FALSE) > Unfortunately, it doesn't work. In fact, read.table(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!)

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

2008-06-05 Thread Alberto Monteiro
he transposition of matrix.in (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/mail

[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 Mon

[R] van der Corput sequences

2008-05-23 Thread Alberto Monteiro
.3, 0.4, 0.5, 0.6, 0.7, 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/m

[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-projec

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

2008-05-07 Thread Alberto Monteiro
m # matpow res=mat.pow(m,6) # Check point all.equal(goal,res) This algorithm would be fast, unless n 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

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

2008-05-06 Thread Alberto Monteiro
n * t(vectors))) > This example only works 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

Re: [R] XML write?

2008-04-29 Thread Alberto Monteiro
and then I can edit the saved file to cut some extra 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

[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 b

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

2008-04-18 Thread Alberto Monteiro
- function(x) x + 1 f2 <- function(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://s

Re: [R] = vs. ==?

2008-04-16 Thread Alberto Monteiro
". The function to use for testing whether (say) > 'x' is "NA" is is.na(x). > Just as an off-topic tangent, I found it quite interesting that real-world language Aymara (see ... http://en.wikipedia.org/wiki/Aymara_language ...) uses this three value logic system (I think

Re: [R] fuzzy merge

2008-04-09 Thread Alberto Monteiro
is d2 for (j in 1:length(d1)) { # again delta.t <- abs(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

Re: [R] generate random numbers subject to constraints

2008-03-26 Thread Alberto Monteiro
ust give more information. How are those numbers 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-h

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 _

Re: [R] How to remove double loop?

2008-03-19 Thread Alberto Monteiro
loop is simple, but somehow tricky. You are computing each j-th term as the same j-th term 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

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

2008-03-19 Thread Alberto Monteiro
uot;Entities should not be needlessly multplied" (Occam's Razor), so let's do it without 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 fa

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

2008-03-12 Thread Alberto Monteiro
10 of the way over from 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 jum

Re: [R] Jpeg and pixel

2008-03-11 Thread Alberto Monteiro
inted at their native 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

[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

Re: [R] Interface or Select menu

2008-03-06 Thread Alberto Monteiro
r interface, with R? or I 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

Re: [R] Excel export into R

2008-03-06 Thread Alberto Monteiro
Venus Aphrodite 1.6 I want 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] write in rimage package

2008-03-06 Thread Alberto Monteiro
m the original file, because there are ugly white 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

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

2008-03-03 Thread Alberto Monteiro
lt;-length(digits) > if(digilen == 2 && digits[2] == 1) return(teens[digits[1]+1]) > digitext<-units[digits[1]] > if(digilen > 1) digitext<-c(digitext,tens[digits[2]]) > if(digilen > 2) digitext<-c(digitext,"hundred",units[digits[3]]) > if(

Re: [R] Bug with curve?

2008-02-01 Thread Alberto Monteiro
n(x) x-x > > no error is generated. > > Is this a bug? > No; simplify it: g1 <- function(x) 0 g2 <- function(x) x - x g1(anything) will return (scalar) 0 g2(scalar) will return (scalar) 0, g2(vector) will return (vector) 0, g2(matrix) will return (ma

[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
robably brazilian or portuguese. Windows, in Portuguese, does a very stupid thing (not as stupid as spaces inside filenames, but a close second): it uses _accented_ characters in filenames and paths. And they are not standard. So there may be a filename conflict here. Alberto Monteiro

Re: [R] 4 dimensional graphics

2008-01-10 Thread Alberto Monteiro
d the direction atan2(y',x') became the hue Probably you could do the same here, 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. Al

Re: [R] load tcltk

2008-01-10 Thread Alberto Monteiro
#x27; konnte nicht geladen werden > Packet 'tcltk' can't be loaded (?) My guess: check if the above mentioned 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 t

Re: [R] An "R is slow"-article

2008-01-09 Thread Alberto Monteiro
n't_ free memory when it finishes, 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/po

[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 Mon

[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
ng like "if (okpressed) xxx else yyy" What > values does this command give and how are they used? > Why don't you test it yourself? library(tcltk) x <- tkmessageBox(title="",message="x",icon="question",type="okcancel&

Re: [R] Communicating from one function to another

2007-11-26 Thread Alberto Monteiro
ot;, but the name is misleading: it should > 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?

Re: [R] Communicating from one function to another

2007-11-26 Thread Alberto Monteiro
out necessarily > 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 <<

[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 d

Re: [R] script fails because of library loading

2007-11-13 Thread Alberto Monteiro
is easy: the error output should go to 2> 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 mailin

Re: [R] R as a programming language

2007-11-08 Thread Alberto Monteiro
) I am using R as a generic programming language for doing jobs in Windows that I can't do using DOS batch - things like taking 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 th

Re: [R] C++ and R interface

2007-11-06 Thread Alberto Monteiro
.) > > Can the same be done for C++ code? > If it can be done in C, it probably (P > 99%) can 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 Montei

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

2007-11-06 Thread Alberto Monteiro
eation time" of its objects... but I have no idea how to do it (I think I 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 re

Re: [R] tcltk: help with tkmenubutton

2007-10-19 Thread Alberto Monteiro
it is evaluated as a Tcl command whenever the entry is invoked. This is not supported 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 r

[R] tcltk: help with tkmenubutton

2007-10-19 Thread Alberto Monteiro
text = "File", underline = 0) # pack everything from the menubar tkpack(mb, side = "top", fill = "x") tkpack(m_file, side = "left") now create the submenus # the file menus # # HERE!!! What is the magic inchantation that I must use here? # # $m_file

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

2007-10-18 Thread Alberto Monteiro
value = now, offvalue = "No time") # (...) # display everything # (...) tkpack(c2, anchor = 'w', fill = 'x') # (...) # enter main event collecting loop - necessary in perl but not in R I tried to contact the author for permissions to translate, adapt and post the examples to

Re: [R] Multi-objective optimization

2007-10-17 Thread Alberto Monteiro
t f(x,y) is max maximize g(x,y) in order to y %means% (2) for every x, find y = g1(x) such that g(x,y) is max simultaneously %means% (3) x = f1(y) and y = g1(x). So, for your example, we would have: (1) => x = y (2) => y = 1 (3) => x = y = 1 Alberto Monteiro _

Re: [R] Import from excel 2007

2007-10-16 Thread Alberto Monteiro
se is writen in Excel 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-hel

Re: [R] Create *png or *.jpeg plot under Linux

2007-10-16 Thread Alberto Monteiro
e user to create horrible filenames (when I become the World's Evil Overlord, I will hunt the jerk that introduced whitespaces in filenames, and send him/her to the paredón), but not under Linux. Alberto Monteiro __ R-help@r-project.org mailing l

Re: [R] Deleting for() loop in function

2007-10-10 Thread Alberto Monteiro
ction then call f(...) Rprof will report that f (and not my.slow.function) was called . I noticed that because I "tested" Rprof with one of my programs that do test cases; these test cases run with an array of functions, by calling each function from the array - precisely what can

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

2007-10-10 Thread Alberto Monteiro
hus: >> >> par(pin=mm2in(126)) > > But be sure to use it consistently! > http://www4.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). Albert

Re: [R] chi2

2007-10-10 Thread Alberto Monteiro
that, probably, will appear after this one - Murphy rulez] 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 comm

Re: [R] chi2

2007-10-10 Thread Alberto Monteiro
o view the probability density function), it's easy so see that chi2 for large n is normal-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/list

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, i

[R] Fill a polygon with a pattern

2007-10-08 Thread Alberto Monteiro
X XXX X XXX (where the border "X"s could be truncated). I searched the rimage package, but it seems that there is no such function. Alberto Monteiro __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-hel

Re: [R] Mouse Location on Plots

2007-10-08 Thread Alberto Monteiro
that package actually be useful?) > A long 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 t

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

2007-10-08 Thread Alberto Monteiro
respond to > independent throws of 10 dice each 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 ___

Re: [R] help in substitute function

2007-10-05 Thread Alberto Monteiro
mmand... RSiteSearch("Replacement in an expression - can't use parse()") ... will get it among others) Quoting and adapting: e <- expression(1+2*pred+3*lat) do.call("substitute", list(e[[1]], list(pred=quote(x1),lat=quote(x2 # 1

[R] grep in filename

2007-10-04 Thread Alberto Monteiro
probably work, but maybe there's a more direct (and less memory 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-

Re: [R] using sprintf with dates

2007-10-02 Thread Alberto Monteiro
e string <- format(Sys.Date, "%s") (or, generically, string <- format(sin, "%s"), etc), but it will just put some description of the function in the string. Also, the assignment in R is "<-", not "=". Try: foot <- function(){ str1 <- forma

Re: [R] wordReport

2007-09-26 Thread Alberto Monteiro
to a XML that can be correctly interpreted by MS-Word? 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 code.

[R] wordReport

2007-09-26 Thread Alberto Monteiro
quot;R rulez!\n"); 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

Re: [R] Calculate difference between dates in years

2007-09-24 Thread Alberto Monteiro
2008-02-28") - as.Date("2007-02-28"))/365.25) # 0, should be 1 Alberto Monteiro (purely destructive - sorry) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://w

[R] Histogram with colors

2007-09-17 Thread Alberto Monteiro
with x >= 0 in lightgreen. Is there any simple way to do it? I think I can do it in two steps: x.hist <- hist(x, plot=FALSE) plot(x.hist, col=c(rep("red", 5), rep("green", 12))) but maybe a more direct way is available. Alberto Monteiro ___

Re: [R] Number -> Fraction

2007-09-13 Thread Alberto Monteiro
ted by rational numbers is transcendental. The number that gets the _worse_ approximations is the ubiquitous Golden Ratio: phi <- (1 + sqrt(5))/2 There's a way to express this precisely, something like |x - p/q| < 1/q^n (http://en.wikipedia.org/wiki/Liouville

Re: [R] Evaluating args in a function

2007-09-12 Thread Alberto Monteiro
adn't known that I could 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