Re: [R] wildcards and removing variables
On Mon, 10 Oct 2005, Marc Schwartz (via MN) wrote: On Mon, 2005-10-10 at 10:37 -0400, Afshartous, David wrote: All, Is there are a wildcard in R for varible names as in unix? For example, rm(results*) to remove all variable or function names that begin w/ results? cheers, Dave ps - please respond directly to [EMAIL PROTECTED] See ?ls, which has a 'pattern' argument, enabling the use of Regex to define the objects to be listed and subsequently removed using rm(). You can then use something like: rm(list = ls(pattern = \\bresults.)) One new feature of R-2.2.0 is glob2rx, which converts wildcards to regexps for you. E.g. rm(list = ls(pattern = glob2rc(results*))) (I think if does it a little better, as that trailing dot is not I think correct: result* matches result.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] passing char to Fortran routine
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Programming questions are appropriate for R-devel, as it says there. The issue is OS-specific, but we don't see what your Fortran code is. If you send a reproducible example to the R-devel list, people may be able to suggest what the problem is. On Mon, 10 Oct 2005, Ingmar Visser wrote: Hello all, I am using an existing Fortran routine that takes a single character string as argument. The routine echoes the argument that I provide. When working on OS X 3.9 there seems to be no problem, ie the Fortran routine nicely echoes my argument. However, I compiled the same package on a PC (using all the tools provided in the R for windows faq), and the routine only echoes the first letter of each character string that I pass on to it. My questions are: 1) Is this somehow compiler specific? 2) Should I explicitly provide the Fortran routine with the length of the character string? 3) I am at a loss as to what is happening here, so any hint is welcome (-; The call to the Fortran routine is as follows: .Fortran(npoptn,as.character(opt),PACKAGE=depmix) where opt is a character string such as opt=Iteration limit = 100 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] greek symbols using pch
This is now well off the topic of the subject line, but I am afraid some misinformation has been propagated (and that is the `bug'). There _are_ bugs in the code shown: the postscript fonts support 32:255, not 1:256, and pch:0:31 are not taken from the font. It seems an uninformed modification of the code in ?postscript. What locale are you in? That's something bug.report() gives and the posting guide asks for (because it often matters). The code given works (albeit with warnings) in an 8-bit locale, but it often will not work in a multi-byte locale. In particular it does not work in a UTF-8 locale for a postcript() device. The help page for points() does point out clearly In a multi-byte locale such as UTF-8, numeric values of \code{pch} greater than or equal to 32 specify a Unicode code point. Thus in UTF-8, pch=167 should be interpreted as a Unicode code point, and that is not a Greek symbol. The problem for postscript() (and X11()) is that the standard font=5 is not encoded in the locale's encoding but Adobe Symbol, so supplying Unicode characters is unsupported. I think R is working as documented here, but the piece of documentation about font=5 is in a different place (it is driver-specific). Internationalization support for the postscript() driver is work in progress (more features will appear in 2.3.0), but at present all you can expect to work in a UTF-8 locale are ISO Latin-1 characters, and symbols via plotmath. (I am aware of a few things that are not quite right in the Unicode support: some are being fixed for 2.3.0.) On Tue, 11 Oct 2005, ecatchpole wrote: On 11/10/05 01:12, Earl F. Glynn wrote,: FISCHER, Matthew [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] In a plot, can I specify pch to be a greek symbol? (I looked at show.pch() in the Hmisc package but couldn't see the right symbols in there). If not, I guess I can get around this using text(x,y,expression()). I'm not sure where this is explained very well. Having ?font give a clue about this would be nice. Use font=5, the symbol font. To see what's in font=5: par(font=5, las=1) plot(0:15,0:15,type=n,ylim=c(15,0), main=Symbols in Font=5, xlab=, ylab=,xaxt=n, yaxt=n) axis(BOTTOM-1, at=0:15, 1:16) axis(LEFT -2, at=0:15) abline(v=0.5 + 0:14, h=0.5 + 0:14, col=grey, lty=dotted) # pch index of any cell is 16*row + column for(i in 0:255) { x - i %%16; y - i %/% 16; points(x,y,pch=i+1) } When I execute this code, I get a calligraphic R or P occurring with all of the nifty characters, e.g. \clubsuit. For example par(font=5, las=1) plot(0:1, 0:1, type=n) points(.5, .5, pch=167) This occurs on screen and in postscript() output. And with R2.1.0 and R2.2.0. Is this a bug? Ted. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] Writing to a file with fixed precision
On Mon, 10 Oct 2005, Marc Schwartz wrote: On Mon, 2005-10-10 at 19:50 -0400, Richard Hedger wrote: Hi, I'm trying to ouput to a filled with a fixed precision: eg. if I have data x=c(1.0,1.4,2.0), I want to be able to ouput the following to a file: 1.00 1.40 2.00 I was wondering if there was a function to do this in R? Thanks, Richard It is possible that someone has written such a function somewhere. It's called format(). x - c(1.0,1.4,2.0) write(format(x, nsmall=14)) does this. However, this is relatively easy using write.table(). You just need to pre-format the numeric values prior to writing to the file: write.table(sprintf(%.14f, x), data.txt, col.names = FALSE, row.names = FALSE, quote = FALSE) Using sprintf(), we force the floats to have 14 decimal places. sprintf() outputs character vectors, so we remove the quoting of the resultant character vectors and don't write column/row names. Note that if 'x' is a matrix, using sprintf() will return a vector. So you might want to use the following instead to retain the dims: x [,1] [,2] [,3] [,4] [1,]147 10 [2,]258 11 [3,]369 12 x.fmt - apply(x, 1, function(x) sprintf(%.14f, x)) x.fmt [,1][,2][,3] [1,] 1.00 2.00 3.00 [2,] 4.00 5.00 6.00 [3,] 7.00 8.00 9.00 [4,] 10.00 11.00 12.00 write.table(x.fmt, data.txt, col.names = FALSE, row.names = FALSE, quote = FALSE) If needed, you can of course change the default delimiter from a to another character in write.table(). See ?write.table and ?sprintf. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] knn
Please do read the posting guide and supply a reproducible example as it asks. Here it matters critically what you mean by `fix l' (to what value?). Is this knn in package class? Have you read the help page? Have you read the references (especially the first)? On Tue, 11 Oct 2005, Haleh Yasrebi wrote: Why do I get doubt (NA) in the factor of test classification even if I fix l (minimum vote)? By setting l, no doubt should be occurred. That is completely opposite to what the help page for knn in package class says happens, so why do you think so? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] Q: Suggestions for long-term data/program storage policy?
On Tue, 11 Oct 2005, Alexander Ploner wrote: we are a statistical/epidemiological departement that - after a few years of rapid growth - finally is getting around to formulate a general data storage and retention policy - mainly to ensure that we can reproduce results from published papers/theses easier in the future, but also with the hope that we get more synergy between related projects. We have formulated what we feel is a reasonable draft, requiring basically that the raw data, all programs to create derived data sets, and the analysis programs are stored and documented in a uniform manner, regardless of the analysis software used. The minimum data retention we are aiming for is 10 years, and the format for the raw data is quite sane (either flat ASCII or real You are intending to retain copies of the OS used and hardware too? The results depend far more on those than you apparently realize. Given the rapid devlopment cycle of R, I think you will find your OS changes as fast: all those security updates potentially affect your results. this suggests that at the very least all non-base packages used in the analysis are stored together with each project. I have basically two questions: 1) Are old R versions (binaries/sources) going to be available on CRAN indefinitely? Not binaries. The intention is that source files be available, but they could become corrupted (as it seems the Windows binary has for a past version). 2) Is .RData a reasonable file format for long term storage? I would say not, as it is almost impossible to recover from any corruption in such a file. We like to have long-term data in a human-readable printout, with a print copy, and also store some checksums. I would also be very grateful for any other suggestions, comments or links for setting up and implementing such a storage policy (R- specific or otherwise). You need to consider the medium on which you are going to store the archive. We currrently use CD-R (and not tapes as those are less compatible across drives -- we have two identical drives currently but do not expect either to last 10 years), and check them annually -- I guess we will re-write to another medium after much less than 10 years. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] probs in installing packages with R 2.2.0
I expect you need to set a proxy. This is covered in the rw-FAQ that we do ask you to read before posting. See the item The internet download functions fail. On Tue, 11 Oct 2005, Giannitrapani, Marco GSUK-GSSC wrote: Dear R users. I was wondering if you could help me with this error message I get when I try to install packages. I just installed R (the latest version, R 2.2.0) on my laptop (windows), and I was trying to install packages intwo ways: 1) Packages Install Package(s)... 2) Packages Install Package(s) from local zip files... , but in both ways I get the following error message: Warning: unable to access index for repository http://cran.uk.r-project.org/bin/windows/contrib/2.2 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.2 Error in install.packages(NULL, .libPaths()[1], dependencies = TRUE, type = type) : no packages were specified PS: I try selecting my CRAN mirror from different parts (UK, USA, ...), but it doesn't work Any idea, what is wrong with that? Should I install something before installing packages? Thanks in advance for your help! Cheers, Marco [[alternative HTML version deleted]] __ 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 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] Under-dispersion - a stats question?
On Mon, 10 Oct 2005, Martin Henry H. Stevens wrote: Hello all: I frequently have glm models in which the residual variance is much lower than the residual degrees of freedom (e.g. Res.Dev=30.5, Res.DF = 82). Is it appropriate for me to use a quasipoisson error distribution and test it with an F distribution? It seems to me that I could stand to gain a much-reduced standard error if I let the procedure estimate my dispersion factor (which is what I assume the quasi- distributions do). Thank you for any input at all. This usually indicates a deviation from the large-sample theory because of small counts. See e.g. MASS4 p.208. Then estimator residual variance - residual degrees of freedom is unreliable. If the better methods discuss there confirm under-dispersion, then you probably have some form of negative correlation and need to look at your experimental setup. (But it is usually are false alarm.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] step.gam and number of tested smooth functions
step.gam is a tricky function to use correctly. You will need to consult the original documentation (in Chambers Hastie ca 1992) or ask the package author for help. BTW, it uses loess not lowess. On Wed, 12 Oct 2005 [EMAIL PROTECTED] wrote: Hi, I'm working with step.gam in gam package. I'm interested both in spline and lowess functions and when I define all the models that I'm interested in I get something like that: gam.object.ALC-gam(X143S~ALC,data=dane,family=binomial) step.gam.ALC-step.gam(gam.object.ALC,scope=list(ALC=~1+ALC+s(ALC,2)+s(ALC,3)+s(ALC,4)+s(ALC,6)+s(ALC,8)+lo(ALC,degree=1,span=.5)+lo(ALC,degree=2,span=.5)+lo(ALC,degree=1,span=.25)+lo(ALC,degree=2,span=.25))) Start: X143S ~ ALC; AIC= 104.0815 Trial: X143S ~ 1; AIC= 111.1054 Trial: X143S ~ s(ALC, 2); AIC= 103.3325 Step : X143S ~ s(ALC, 2) ; AIC= 103.3325 Trial: X143S ~ s(ALC, 3); AIC= 102.9598 Step : X143S ~ s(ALC, 3) ; AIC= 102.9598 Trial: X143S ~ s(ALC, 4); AIC= 102.2103 Step : X143S ~ s(ALC, 4) ; AIC= 102.2103 Trial: X143S ~ s(ALC, 6); AIC= 102.4548 I have impression that the algorithm stops when the next trial gives higher AIC without examining further functions. When I deleted some of the spline functions that were worse than s(ALC,4) I got: step.gam.ALC-step.gam(gam.object.ALC,scope=list(ALC=~1+ALC++s(ALC,4)+lo(ALC,degree=1,span=.5)+lo(ALC,degree=2,span=.5)+lo(ALC,degree=1,span=.25)+lo(ALC,degree=2,span=.25))) Start: X143S ~ ALC; AIC= 104.0815 Trial: X143S ~ 1; AIC= 111.1054 Trial: X143S ~ s(ALC, 4); AIC= 102.2103 Step : X143S ~ s(ALC, 4) ; AIC= 102.2103 Trial: X143S ~ lo(ALC, degree = 1, span = 0.5); AIC= 99.8127 Step : X143S ~ lo(ALC, degree = 1, span = 0.5) ; AIC= 99.8127 Trial: X143S ~ lo(ALC, degree = 2, span = 0.5); AIC= 100.5275 Lowess turned out to be better in this situation. Is there any way to examine all the models without stopping when AIC is higher in the next trial? Or maybe manual handling is the only solution? thanks for help in advance Agnieszka Strzelczak __ 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 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] adding 1 month to a date
On Wed, 12 Oct 2005, bogdan romocea wrote: Simple addition and subtraction works as well: as.Date(1995/12/01,format=%Y/%m/%d) + 30 If you have datetime values you can use strptime(1995-12-01 08:00:00,format=%Y-%m-%d %H:%M:%S) + 30*24*3600 where 30*24*3600 = 30 days expressed in seconds. Sorry, not in general, as a month is not generally of 30 days (including in your example). seq.Date is a good way to do this. -Original Message- From: Marc Schwartz [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 11, 2005 10:16 PM To: t c Cc: r-help@stat.math.ethz.ch Subject: Re: [R] adding 1 month to a date On Tue, 2005-10-11 at 16:26 -0700, t c wrote: Within an R dataset, I have a date field called date_. (The dates are in the format -MM-DD, e.g. 1995-12-01.) How can I add or subtract 1 month from this date, to get 1996-01-01 or 1995-11-01. There might be an easier way to do this, but using seq.Date(), you can increment or decrement from a Time 0 by months: Add 1 month: This takes your Time 0, generates a 2 element sequence (which begins with Time 0) and then takes the second element: seq(as.Date(1995-12-01), by = month, length = 2)[2] [1] 1996-01-01 Subtract 1 month: Same as above, but we use 'by = -1 month' and take the second element: seq(as.Date(1995-12-01), by = -1 month, length = 2)[2] [1] 1995-11-01 See ?as.Date and ?seq.Date for more information. The former function is used to convert from a character vector to a Date class object. Note that in your case, the date format is consistent with the default. Pay attention to the 'format' argument in as.Date() if your dates should be in other formats. HTH, Marc Schwartz __ 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 __ 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 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] running JPEG device on R 1.9.1 using xvfb-run on Linux
On Wed, 12 Oct 2005, David Zhao wrote: Does anybody have experience in running jpeg device using xvfb-run on linux? I've been having sporadic problem with: /usr/X11/bin/xvfb-run /usr/bin/R --no-save Rinput.txt, with error saying: error in X11 connection. Especially when I run it from a perl script. Not sure what `xvfb-run on Linux' is, as it is not on my Linux (FC3). If you Google it you will find a number of problems reported on Debian lists. Here I would suspect timing. What I do is to run Xvfb on screen 5 by Xvfb :5 setenv DISPLAY :5 and do not have a problem with the jpeg() or png() devices. I do have a problem with the rgl() package, but then I often do on-screen (on both 32- and even more so 64-bit FC3). Is there a better way of doing this? or how can I fix the problem. You really should update your R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] About Qusi-Monte carlo program
I suspect you mean `Quasi-Monte Carlo', but that is used to do integration not simulation. Using help.search led ne to LowDiscrepancy(fOptions) Low Discrepancy Sequences QUnif(sfsmisc) Quasi Randum Numbers via Halton Sequences both of which generate the integration points for Quasi-Monte Carlo. On Wed, 12 Oct 2005, Zhao Yang wrote: Dear Listers; Does anybody has experience in doing simulation via Qusi-Monte carlo in R or S-plus, if so, could you like to send a small copy of your program to me, I appreciate and thanks in advance!! Frankly speaking, I am struggling to write this kind of program, while I could not figure out, painful! Best regards, Tony [[alternative HTML version deleted]] __ 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 PLEASE do, and not send HTML mail as it asks. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] Optim with two constraints
This is actually quadratic programming, so why do you want to use optim()? There are packages specifically for QP, e.g. quadprog. A more general approach is to eliminate one variable, which gives you an inequality constrained problem in n-1 variables to which you could apply contrOptim(). Other re-parametrizations (e.g. of weights as a log-linear model) will work provided none of the parameters are going to be zero at the optimum (one cannot be one without all the others being zero). On Wed, 12 Oct 2005, Jens Hainmueller wrote: Hi R-list, I am new to optimization in R and would appreciate help on the following question. I would like to minimize the following function using two constraints: ## fn - function(par,H,F){ fval - 0.5 * t(par) %*% H %*% par + F%*% par fval } # matrix H is (n by k) # matrix F is (n by 1) # par is a (n by 1) set of weights # I need two constraints: # 1. each element in par needs to be between 0 and 1 # 2. sum(par)=1 i.e. the elements in par need to sum to 1 ## I try to use optim res - optim(c(runif(16),fn, method=L-BFGS-B, H=H, F=f ,control=list(fnscale=-1), lower=0, upper=1) ## If I understand this correctly, using L-BFGS-B with lower=0 and upper=1 should take care of constraint 1 (box constraints). What I am lacking is the skill to include constraint no 2. I guess I could solve this by reparametrization but I am not sure how exactly. I could not find (i.e. wasn't able to infer) the answer to this in the archives despite the many comments on optim and constrained optimization (sorry if I missed it there). I am using version 2.1.1 under windows XP. Thank you very much. Jens __ 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 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] drawing against a date
On Thu, 13 Oct 2005, [EMAIL PROTECTED] wrote: hy all I wish to draw a graph against a date, I have a set of date like this DD/MM/, corresponding to it a set of integer , i wish to draw on x side the dates (the space between the dates have to be constant, not based on the time between 2 dates but on the number of dates) and on y side the integers. Do i have to make a tricky function under R ? I've search the help for graphical functions but my poor english seems to make me missing the solution... First convert your dates to R's date format by as.Date, then see ?plot.Date. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] Help with Matrix package
The first thing is to ensure that you are using an optimized BLAS. On Windows, use Goto's BLAS if you have it (is not currently available and redistribution is not allowed) or one of the pre-built ATLAS-based Rblas.dll on CRAN or (best of all) optimize your own build of ATLAS. The Matrix package depends on an optimized BLAS even more crucially than base R. On Thu, 13 Oct 2005, rob foxall (IFR) wrote: Hello all, A colleague at work set me the challenge to convert some MATLAB code into R, to see which is faster. We'd seen that benchmark comparing MATLAB 6.5 to R1.90 (and others), and so I thought that I should be able to get roughly comparable speeds. The code has lots of multiplications of matrixes, transposes, and MATLAB's repmat. I did the code conversion, and R was about 6 times slower, so I had a closer look at the benchmark comparison and it seems that I should be using the Matrix package. Is there any dummies-level help available for this package? I am struggling even to apply simple functions such as sum and mean to matrixes constructed from this class (not that I need to yet), and more importantly kronecker, to convert from repmat. (The help for kronecker from the Matrix package doesn't seem to mention kronecker, so I am a bit stuck). Any guidance greatly accepted -- I have read the overview, looked through the various Matrix-listed functions, and unsuccessfully tried searching R-help. Using R version 2.2.0, windows xp. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] Do Users of Nonlinear Mixed Effects Models Know Whether Their Software Really Works?
On Thu, 13 Oct 2005, dave fournier wrote: Internal Virus Database is out-of-date. Talk about not being careful! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] arima: warning when fixing MA parameters.
It's a bug: the code has 1:arma[1], i.e. 1:0. Replace by seq(length=arma[1]). On Thu, 13 Oct 2005, John Maindonald wrote: I am puzzled by the warning message in the output below. It appears whether or not I fit the seasonal term (but the precise point of doing this was to fit what is effectively a second seasonal term). Is there some deep reason why AR parameters (Warning message: some AR parameters were fixed: ...) should somehow intrude into the fitting of a model that has only MA terms? library(DAAG) attach(bomsoi) # The following is fine: arima(avrain, order=c(0,0,4), seasonal=list(order=c(0,0,1), period=12), + fixed=c(NA,0,0,NA,NA,NA)) . # The following generates a warning message arima(avrain, order=c(0,0,4), seasonal=list(order=c(0,0,1), period=12), + fixed=c(0,0,0,NA,NA,NA)) Call: arima(x = avrain, order = c(0, 0, 4), seasonal = list(order = c(0, 0, 1), period = 12), fixed = c(0, 0, 0, NA, NA, NA)) Coefficients: ma1 ma2 ma3 ma4 sma1 intercept 000 0.0357 -0.1061 456.6675 s.e.000 0.1015 0.0886 7.6997 sigma^2 estimated as 6849: log likelihood = -595.23, aic = 1198.46 Warning message: some AR parameters were fixed: setting transform.pars = FALSE in: arima(avrain, order = c(0, 0, 4), seasonal = list(order = c(0, John Maindonald email: [EMAIL PROTECTED] phone : +61 2 (6125)3473fax : +61 2(6125)5549 Centre for Bioinformation Science, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. __ 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 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] fast and stable way to read data in R
On Fri, 14 Oct 2005, Wensui Liu wrote: Dear useRs, I am wondering what is the most fast and stable way to read data (pretty large) into R. Right now, the methods I could think of are: 1) use read.table to read *.csv or *txt 2) use RODBC to read excel or access But I don't know which is better. Depends on the data and how large is `pretty large'. If your data are numeric, 2) will be faster as you will avoid numeric-character-numeric conversions. If your data are to be factors, 1) might be as fast. However, both are pretty much instantaneous unless you have millions of items to read (and Excel is unlikely to cope well with such numbers). I just tested reading 1 million numbers from an 18Mb file in 3s with read.table(). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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
Re: [R] How to find S4 generics?
On Wed, 19 Jul 2006, Spencer Graves wrote: Dear Prof. Ripley: Thanks very much. Am I correct then that the 'methods' function could, at least theoretically, be revised so methods(class=...) could identify both S3 and S4 methods (ignoring inheritance, as it does now, I believe)? It is correct that in principle there could be such a function in the methods package, but not that methods() in utils could be revised to do so. (For efficiency reasons on the stats4 package in the base distribution may depend on methods) I ask, because it's not always obvious (at least to me) what helper functions are available. Some but not all are mentioned in the documentation, and even if they are, they may not be featured prominently. For the S3 standard, methods(class=...) reports what's available, and it's faster and more reliable than scanning the help files. After I find something with methods(class=...), then I have better ideas for what to look for in the documentation. Best Wishes, Spencer Graves Prof Brian Ripley wrote: On Tue, 18 Jul 2006, Spencer Graves wrote: * * methods * * You have asked an excellent question. I can provide a partial answer below. First, however, I wish to pose a question of my own, which could help answer your question: How can one obtain a simple list of the available generics for a class? For an S3 class, the 'methods' functions provide that. What about an S4 class? That's entirely opaque to me, if I somehow can't find the relevant information in other ways. For example, ?lmer-class lists many but not all of the methods available for objects of class 'lmer'. I think I once found a way to get that, but I'm not able to find documentation on it now. It doesn't work the same way. S3 generics are defined on a single argument and hence have methods for a class, and so it is relevant to ask what generics there are which have methods for a given class - but even then there can be other generics and other methods which dispatch on object from that class by inheritance (e.g. on lm for glm objects). S4 generics dispatch on a signature which can involve two or more classes, and I guess the simplest interpretation of your question is `what S4 generics are there which have methods with signatures mentioning this class'. Given the decentralized way such information is stored, I think the only way to do that is to find all the generics currently available (via getGenerics or its synonym allGenerics) and then call showMethods on each generic. In particular, methods are stored in the S4 generic and not in the package defining the method. However, I suspect inheritance is much more important here, and there is no way to know if methods for class ANY actually work for a specific S4 class. [...] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] error when compiling stats library in R-2.3.1 on Solaris x86
How did 'cc -xtarget=generic64' get there? AFAIK R does not know about it, so presumably you specified it for CC. You need to do the same thing for *all* the compilers, that is CC, CXX, F77 and FC. The INSTALL file asked you to read the R-admin manual: there you will find a very similar example for 64-bit Sparc Solaris. That uses -xarch, which seems preferred to -xtarget (or at least to generic targets). On Wed, 19 Jul 2006, Dongseok Choi wrote: Hello, I tried to compile v2.3.1 on Solaris x86 with SUN Pro compilers. I had an error while stats libarary was being compiled and I notice that -xtarget=generic64 was not passed to f95 while cc used it. Could you tell me how to fix this problem? f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c sgram.f -o sgram.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c sinerp.f -o sinerp.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c sslvrg.f -o sslvrg.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c stxwx.f -o stxwx.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c hclust.f -o hclust.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c kmns.f -o kmns.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c eureka.f -o eureka.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c stl.f -o stl.o f95 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c portsrc.f -o portsrc.o cc -xtarget=generic64 -G -L/mounts/devel/SUNWspro/lib/amd64 -L/usr/sfw/lib/amd64 -L/mounts/devel/GNU/repoz/readline43/lib/amd64 -o stats.so init.o kmeans.o ansari.o bandwidths.o chisqsim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o swilk.o ksmooth.o loessc.o isoreg.o Srunmed.o Trunmed.o dblcen.o distance.o hclust-utils.o nls.o HoltWinters.o PPsum.o arima.o burg.o filter.o mAR.o pacf.o starma.o port.o family.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sbart.o sgram.o sinerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o portsrc.o -xlic_lib=sunperf -lsunmath -Rreg -R/mounts/devel/SUNWspro/lib/amd64:/opt/SUNWspro/lib/amd64 -L/mounts/devel/SUNWspro/prod/lib/amd64 -L/lib/amd64 -L/usr/lib/amd64 -lfui -lfai -lfsu -lsunmath -lmtsk -lm ld: fatal: file bsplvd.o: wrong ELF class: ELFCLASS32 ld: fatal: File processing errors. No output written to stats.so *** Error code 1 make: Fatal error: Command failed for target `stats.so' I did not have any problem when I compiled v2.2.1 as below: cc -xtarget=generic64 -I../../../../include -I/mounts/devel/SUNWspro/prod/include -I/mounts/devel/GNU/repoz/readline43/include -D__NO_MATH_INLINES -KPIC -O -I/mounts/devel/SUNWspro/prod/include -c family.c -o family.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c bsplvd.f -o bsplvd.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c bvalue.f -o bvalue.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c bvalus.f -o bvalus.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c loessf.f -o loessf.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c ppr.f -o ppr.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c qsbart.f -o qsbart.o cc -xtarget=generic64 -I../../../../include -I/mounts/devel/SUNWspro/prod/include -I/mounts/devel/GNU/repoz/readline43/include -D__NO_MATH_INLINES -KPIC -O -I/mounts/devel/SUNWspro/prod/include -c sbart.c -o sbart.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c sgram.f -o sgram.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c sinerp.f -o sinerp.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c sslvrg.f -o sslvrg.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c stxwx.f -o stxwx.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c hclust.f -o hclust.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c kmns.f -o kmns.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c eureka.f -o eureka.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c stl.f -o stl.o f95 -xtarget=generic64 -PIC -O -I/mounts/devel/SUNWspro/prod/include -c portsrc.f -o portsrc.o cc -xtarget=generic64 -G -L/mounts/devel/SUNWspro/lib/amd64 -L/usr/sfw/lib/amd64 -L/mounts/devel/GNU/repoz/readline43/lib/amd64 -o stats.so init.o kmeans.o ansari.o bandwidths.o chisqsim.o d2x2xk.o fexact.o kendall.o ks.o line.o smooth.o prho.o swilk.o ksmooth.o loessc.o isoreg.o Srunmed.o Trunmed.o dblcen.o distance.o hclust-utils.o nls.o HoltWinters.o PPsum.o arima.o burg.o carray.o filter.o mburg.o myw.o pacf.o qr.o starma.o port.o family.o bsplvd.o bvalue.o bvalus.o loessf.o ppr.o qsbart.o sbart.o sgram.o sinerp.o sslvrg.o stxwx.o hclust.o kmns.o eureka.o stl.o
Re: [R] Automating package building packages and repository uploading
On Thu, 20 Jul 2006, Carlos J. Gil Bellosta wrote: Dear Rusers, I have developed two packages for a client of mine. After new features are added or bugs corrected, I upload them to my own web repository. I create both source and binary versions. binary Linux packages, it seems. The latter are .tar.gz with the arch as part of the name. .zip is used for Windows packages only. update.packages for Linux is designed to look for source packages only: see the 'type' argument. You can use the distro's packaging facilities for binary packages, and Dirk does for the Debian R distribution. I think those misconceptions explain your confusion. In fact, I made an script that checks, builds, and uploads them via ftp. However, I am facing two nuisances that do make it difficult to automate: 1) Even if I build the binary version with the command R CMD build --use-zip --binary $package within my script, the output package still gets tarballed and gzipped instead than simply zipped. I come around this automatically extracting and compressing back the files but, am I missing something some other option that would make all this simpler? 2) I expect my packages to be named something like mypackage_1.3.12.tar.gz or mypackage_1.3.12.zip. However, sometimes --I haven't looked at the code that decides the name to give to the packages, so it looks quite random to me-- they get renamed into something like mypackage_1.3.12_R_i486-pc-linux-gnu.tar.gz or mypackage_1.3.12_R_i486-pc-linux-gnu.zip. The problem is that, then, the update.packages() function cannot find them. Is there a way to prevent this trailing string from appearing in the file name? Or else, is there a way to have update.packages() find the package regardless of it? I am running platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) on Debian Etch with kernel 2.6.15-1-k7. Thank you very much. Carlos J. Gil Bellosta http://www.datanalytics.com http://www.data-mining-blog.com -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Automating package building packages and repository uploading
On Thu, 20 Jul 2006, Carlos J. Gil Bellosta wrote: Dear Rusers, Well, then it seems that the problem is that I am building linux binary packages. Since I do not have any compiled code within --just R code--, their contents should --and, in fact, are-- directly installable on Windows platforms (which is what I intend to do). If I understand things right, I could just rebundle the packages using zip instead of tar | gzip and getting rid of the arch string in the file name. They they would work on Windows. And they actually do when I do this by hand. But, is there a less involved way to generate these binary Windows packages with proper file names and compression method directly from my linux box? `involved'? Not anything like as involved as working out what it is you are trying to do from your description which made no mention anywhere of Windows! You can cross-compile the packages on your Linux box if you prefer, which will give you zips with the right file names. Either way, you will be missing Compiled HTML help, which is likely to be the default form on Windows help in the next release of R. Thank you very much, Carlos J. Gil Bellosta http://www.datanalytics.com http://www.data-mining-blog.com Quoting Prof Brian Ripley [EMAIL PROTECTED]: On Thu, 20 Jul 2006, Carlos J. Gil Bellosta wrote: Dear Rusers, I have developed two packages for a client of mine. After new features are added or bugs corrected, I upload them to my own web repository. I create both source and binary versions. binary Linux packages, it seems. The latter are .tar.gz with the arch as part of the name. .zip is used for Windows packages only. update.packages for Linux is designed to look for source packages only: see the 'type' argument. You can use the distro's packaging facilities for binary packages, and Dirk does for the Debian R distribution. I think those misconceptions explain your confusion. In fact, I made an script that checks, builds, and uploads them via ftp. However, I am facing two nuisances that do make it difficult to automate: 1) Even if I build the binary version with the command R CMD build --use-zip --binary $package within my script, the output package still gets tarballed and gzipped instead than simply zipped. I come around this automatically extracting and compressing back the files but, am I missing something some other option that would make all this simpler? 2) I expect my packages to be named something like mypackage_1.3.12.tar.gz or mypackage_1.3.12.zip. However, sometimes --I haven't looked at the code that decides the name to give to the packages, so it looks quite random to me-- they get renamed into something like mypackage_1.3.12_R_i486-pc-linux-gnu.tar.gz or mypackage_1.3.12_R_i486-pc-linux-gnu.zip. The problem is that, then, the update.packages() function cannot find them. Is there a way to prevent this trailing string from appearing in the file name? Or else, is there a way to have update.packages() find the package regardless of it? I am running platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) on Debian Etch with kernel 2.6.15-1-k7. Thank you very much. Carlos J. Gil Bellosta http://www.datanalytics.com http://www.data-mining-blog.com -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Help on making code faster-would C help ?
Without details it is hard to say, but if you do the WLS via lm.wfit, probably not. If you are using lm() and taking the overhead 1 times, that is the first thing to avoid. As an example of this sort of thing, look at the C code for lqs{MASS} which does thousands of regressions quite quickly. On Thu, 20 Jul 2006, Benn Fine wrote: Using R on windows I have the following code for(i in 1:1) { draw some random weights perfom a weighted least squares regression some simple addition and multiplication } The code works fine but is slow. I have mingw installed and can dyn.load, although I am more used to doing this on Unix than Windows. Would it make sense to re-write the whole thing in C ? I am vectorizing the random draws-the speed culprit is looping and the matrix manipulations. My guess is to use the matrix routines from gls-does this sound feasible ? Thanks! __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] how to print table with more columns per row?
This is controlled by options(width): characters not columns. On Thu, 20 Jul 2006, [EMAIL PROTECTED] wrote: When printing a table it is broken at some point (depending how long are the associated names) see example below. Is there a way to control number of columns being printed for a given chunk of the table? Best regards, Ryszard z5 AAA BBB CCC DDD EEE FFF GGG HHH III AAA1.00 -0.69 -0.54 -0.88 NA NA NA NA -0.88 BBB -0.691.000.650.82 NA NA NA 1 0.83 CCC -0.540.651.000.49 NA NA NA NA 0.94 DDD -0.880.820.491.00 NA NA NA 1 0.90 EEE NA NA NA NA NA NA NA NA NA FFF NA NA NA NA NA NA NA NA NA GGG NA NA NA NA NA NA NA NA NA HHH NA1.00 NA1.00 NA NA NA 1 NA III -0.880.830.940.90 NA NA NA NA 1.00 JJJ NA NA NA NA NA NA NA NA NA KKK0.050.210.11 -0.11 NA NA NA 1 NA LLL0.73 -0.68 -0.16 -0.91 NA NA NA -1 -0.35 JJJ KKK LLL AAA NA0.050.73 BBB NA0.21 -0.68 CCC NA0.11 -0.16 DDD NA -0.11 -0.91 EEE NA NA NA FFF NA NA NA GGG NA NA NA HHH NA1.00 -1.00 III NA NA -0.35 JJJ NA NA NA KKK NA1.000.24 LLL NA0.241.00 CONFIDENTIALITY NOTICE\ \ The information contained in this ...{{dropped}} __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Q. regarding optim()
On Fri, 21 Jul 2006, N. Goodacre wrote: Dear R mailing group, The second parameter for the function optim()is a function whose parameters are to be optimized. The description of this function given in the help file is the following: fn: A function to be minimized (or maximized), with first argument the vector of parameters over which minimization is to take place. It should return a scalar result. Let's say the second argument is x, a vector of x values But it says `parameters'. Please look at the examples on that help page. optim is concerned with optimizing functions of more than one parameter. In a statistical setting 'x' may be the data, but e.g. for fitting a gamma distribution c(scale, shape) are the parameters. I would have thought that fn should return a vector full of y values for the x values entered as the second argument. If the function just takes one value at a time and outputs a scalar, how can I specify for fn which x value, of the vector x, to take? Sincerely, Norman Goodacre __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Parameterization puzzle
R does not know that poly(age,2) and poly(age,1) are linearly dependent. (And indeed they only are for some functions 'poly'.) I cannot reproduce your example ('l' is missing), but perhaps glm(deaths ~ poly(age,2) + poly(age,1)*Smoke + offset(l), poisson) was your intention? On Fri, 21 Jul 2006, Murray Jorgensen wrote: Consider the following example (based on an example in Pat Altham's GLM notes) pyears - scan() 18793 52407 10673 43248 5710 28612 2585 12663 1462 5317 deaths - scan() 2 32 12 104 28 206 28 186 31 102 Smoke - gl(2,1,10,labels=c(No,Yes)) Age - gl(5,2,10,labels=c(35-44,45-54,55-64,65-74,75-84), ordered=TRUE) mod1.glm - glm(deaths ~ Age * Smoke + offset(l),family=poisson) summary(mod1.glm) age - as.numeric(Age) mod2.glm - aso1.glm - glm(deaths ~ poly(age,2) + Smoke + poly(age,1):Smoke + offset(l),family=poisson) summary(mod2.glm) The business part of the summary for the first model Estimate Std. Error z value Pr(|z|) (Intercept)-5.927060.16577 -35.754 2e-16 *** Age.L 4.064900.47414 8.573 2e-16 *** Age.Q -1.082930.41326 -2.620 0.008781 ** Age.C 0.241580.31756 0.761 0.446816 Age^4 0.042440.23061 0.184 0.853986 SmokeYes0.619160.17296 3.580 0.000344 *** Age.L:SmokeYes -1.312340.49267 -2.664 0.007729 ** Age.Q:SmokeYes 0.390430.43008 0.908 0.363976 Age.C:SmokeYes -0.295930.33309 -0.888 0.374298 Age^4:SmokeYes -0.036820.24432 -0.151 0.880218 inspires me to fit the second model that omits the nonsignificant terms, however this produces the summary Estimate Std. Error z value Pr(|z|) (Intercept)-5.8368 0.1213 -48.103 2e-16 *** poly(age, 2)1 3.9483 0.1755 22.497 2e-16 *** poly(age, 2)2 -1.0460 0.1448 -7.223 5.08e-13 *** SmokeYes0.5183 0.1262 4.106 4.02e-05 *** SmokeNo:poly(age, 1)1.3755 0.4340 3.169 0.00153 ** SmokeYes:poly(age, 1) NA NA NA NA Why do we get a SmokeNo:poly(age, 1) term? Can I re-express mod2.glm so that this term does not appear? Cheers, Murray Jorgensen -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] from character to numeric over multiple columns
Are the columns factors or character? I'll try to write code that copes with both: nm - unique(c(as.character(col1), as.character(col2), as.character(col3))) DF[] - lapply(DF, function(x) match(x, nm)) On Fri, 21 Jul 2006, Federico Calboli wrote: Hi All, I have a data frame of three columns, all of which names. The names in the three cols overlap up to a point, so I might have *Harry* in all three columns, *Tom* in cols 1 and 3 and *Bob* in col 3 only. harry paulbob anita harry tom frank jackharry tom peteben I want to turn the names into numbers, BUT I want the numeric code for, say, *Harry*, to be the same on all columns. Doing cbind(as.numeric(col1), as.numeric(col2), as.numeric(col3)) does not work because the factors are different in each column, hence they get a different number even though the name is the same. Ideas? Cheers Federico -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] glm cannot find valid starting values
On Fri, 21 Jul 2006, Dan Bebber wrote: glm(S ~ -1 + Mdif, family=quasipoisson(link=identity), start=strt, sdat) gives error: Error in glm.fit(x = X, y = Y, weights = weights, start = start, etastart = etastart, : cannot find valid starting values: please specify some strt is set to be the coefficient for a similar fit glm(S ~ -1 + I(Mdif + 1),... i.e. (Mdif + 1) is a vector similar to Mdif. The error appears to occur when some values of Mdif are negative, though I have not had this problem with simulated datasets. Right: if Mdif contains both positive and negative values there are no coefficients that are valid for that model (you are bound to predict negative means). You often do better to take etastart from another fit than start, but that will not help here, I believe. BTW, your example cannot be pasted in as 'sdat' self-references. It could be fixed, but I gave up at that point. Any solutions greatly appreciated (full details and data below). Dan Bebber Department of Plant Sciences University of Oxford OS: WinXP Pro SP2 and Win ME (tried both) Processor: Dual Intel Xeon and Pentium 4 (tried both) R version: 2.3.0 and 2.3.1 (tried both) #Full details (can be pasted directly into R): #Data: sdat - data.frame( S = c(0, 0, 0, 0, 28, 0, 1, 7, 0, 0, 39, 2, 0, 0, 40, 0, 0, 0, 0, 0, 0, 15, 0, 0, 3, 0, 0, 0, 2, 0, 3, 0, 30, 0, 20, 0, 1, 0, 0, 1, 21, 0, 0, 4, 14, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 3, 0, 2, 5, 0, 0, 0, 0, 0, 0, 0, 25, 0, 5, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 10, 0, 0, 0, 0, 0, 9, 1, 1, 1, 1, 0, 0, 3, 0, 27, 7, 0, 0, 0, 0, 0, 1, 1, 4, 2, 1, 2, 4, 1, 4, 6, 12, 4, 6, 3, 4, 0, 4, 0, 6, 1, 3, 1, 4, 4, 1, 1, 2, 1, 6, 1, 0, 0, 1, 0, 1, 0, 0, 6, 0, 0, 0, 0, 2, 2, 3, 1, 6, 2, 2, 1, 1, 4, 4, 3, 3, 7, 1, 3, 5, 6, 4, 0, 1, 4, 2, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 4, 0, 0, 1, 0, 2, 0, 0, 1, 2, 0, 4, 0, 2, 0, 3, 0, 2, 2, 0, 4, 0, 2, 0, 1, 2, 3, 0, 0, 0, 0, 3, 1, 0, 0, 0, 3, 2, 1, 2, 1, 1, 2, 0, 0, 3, 3, 1, 0, 1, 1, 2, 0, 1, 0, 1, 0, 1, 3, 2, 0, 0, 2, 1, 0, 1, 0, 0, 0, 0, 0, 0, 4, 2, 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 3, 2, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 4, 1, 0, 0, 1), M = 620+c(0,cumsum(sdat$S[-328]))) #S is the (unknown) number of N individuals that irreversibly change state in a time #interval t. The data provided are a subset of the full data set. #M is the cumulative sum of individuals that have changed state up to t-1. #Assume that the rate of state change is constant (S ~ kM), but the #distribution of S is clustered. #The goal is to estimate N. #N can be estimated by fitting: qpglm - glm(S ~ M, family = quasipoisson(link = identity), sdat) summary(qpglm) N.est - -coef(qpglm)[1]/coef(qpglm)[2] N.est #i.e. x-intercept is minus intercept/slope #To estimate confidence limits on N.est, fit models without intercept to #N.est - M + x, where x is an integer. The model will have the lowest deviance #when x = 0. x - 0 Mdif - N.est - M + x qpglm2 - glm(S ~ -1 + Mdif, family = quasipoisson(link = identity), sdat) summary(qpglm2) #Use analysis of deviance to estimate confidence limits on N.est: disp - summary(qpglm)$dispersion dfres - df.residual(qpglm) dev.res - deviance(qpglm) #From MASS4, p. 210, assume that changes in deviance scaled by #dispersion as |x| increases have an F distribution dev.crit - dev.res+qf(0.95,1,dfres)*disp dev.crit #values of x for which the deviance = dev.crit give approximate 95% confidence limits #on N.est. #The error occurs when x = -91.7: x - -91.7 sdat$Mdif - N.est - sdat$M + x strt - coef(glm(S ~ -1 + I(Mdif+1), family = quasipoisson(link = identity), sdat)) qpglm2 - glm(S ~ -1 + Mdif, family = quasipoisson(link = identity), start=strt, sdat) #The problem is that this interferes with optimization to find values of x for which #deviance = dev.crit __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] : Arial font for text in lattice plots under Linux
This is a question about devices, not lattice per se, so applies to all forms of plotting. For jpeg, you can specify the fonts via the 'fonts' argument: see ?X11. For postscript, you can convert the fonts to Type 1 via e.g. ttf2pt1, or you can use ttf2afm to make .afm files and a postscript interpreter that can handle TrueType fonts. On Fri, 21 Jul 2006, Peter Ho wrote: Hi, I have been asked by a publisher to change the font style of a lattice plot in my manuscript. I have consulted documentation on trellis graphics and the excellent book R graphics, but am still not sure how I could create plots with Arial as the font style for text in the plot. I am running R (Version 2.3.1 (2006-06-01)) under debian Linux. I have msttcorefonts installed. Will it be possible to do this with jpeg() as a device? Or with postscript()? Peter __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] compile R with ACML support | RHEL 4
I doubt if /opt/acml3.5.0/gnu/lib is in your library path (it might be in your ldcache paths). So you need to set LD_LIBRARY_PATH or supply -L Look in config.log to find out what actually happened. BTW: this was more of an R-devel question than R-help. On Sat, 22 Jul 2006, Evan Cooch wrote: Greetings - I'm trying to compile R under GNU/Linux (RHEL 4) on a multi-Opteron box, with ACML support. First, I downloaded and installed ACML 3.5 - GNU version, although I'm not entirely sure what the differences are - from the AMD website. The ACML libraries were installed to /opt/acml3.5.0/ Second, I ran ./configure --with-blas='-lacml' The configure went fine, except that at the end of the output, it reports that readline is the only external library configured. External libraries: readline OK, so next, I try ./configure --with-lapack Same think - only readline is referenced. So, clearly, I'm missing a particular step. I'm guessing that I need to change some environment variable (or two), or tweak something at some other stage, to get R to properly reference the ACML libraries. I'm puzzled why --with-blas='-acml' doesn't do the trick? Suggestions? Pointers to the obvious mistake? Thanks... -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] running jobs in background
On Tue, 25 Jul 2006, Uwe Ligges wrote: Nair, Murlidharan T wrote: Can I run jobs in the background and the check the status of it from time to time in Windows version of R? Depends on your version of Windows. I am running the automatical building of R packages in the background on a Windows Server 2003. Unfortunately, if you are logged on, a windows appears when the job is running. For other jobs such as simulations, I am always using a Linux machine. You can with no window using a decent shell -- I use tcsh.exe, and that should work on any NT-based version of Windows (and others are very old). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] deparse - width.cutoff
On Mon, 24 Jul 2006, johan Faux wrote: I have a question about deparse function in R What is the reason that deparse use an argument like width.cutoff ? Why the maximum cutoff is 500? I was manipulating an R formula and used deparse. Since the length of user's formula was greater then 500, my code didnt work. Why do you want this all on one line? deparse does work, just produces multiple lines if the output exceeeds the cutoff. If you do want it, paste the lines together, as e.g. aov() does. thanks Johan johan Faux [EMAIL PROTECTED] wrote: I have a question about deparse function in R What is the reason that deparse use an argument like width.cutoff ? Why the maximum cutoff is 500? I was manipulating an R formula and used deparse. Since the length of user's formula was greater then 500, my code didnt work. thanks Johan - - See the all-new, redesigned Yahoo.com. Check it out. [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] [Way OT] New hardware
On Wed, 26 Jul 2006, Martin Maechler wrote: Sean == Sean Davis [EMAIL PROTECTED] on Tue, 25 Jul 2006 17:16:02 -0400 writes: Sean Can anyone share experience with opteron versus the Sean xeon (woodcrest) for R under linux? I am looking at Sean using 16-32Gb of ram in a workstation (as opposed to a Sean server). Hmm, not that I'd be an expert... If you want to use so much RAM you want to use a 64-bit architecture and software (OS, libraries, compilers,...), right? AFAIK, that's been known to work well with Opterons and different flavors of Linuxen (e.g. we have dual Opterons, one with Redhat Enterprise and two with Ubuntu 6.06). Now I read that there are 64-bit Xeons with EMT64 (which is said to be Intel's emulation of AMD64), so in principle the same versions of Linux and R should run there as well. Since I haven't heard of any success stories I'm interested as well, in reports from R users. There have been several posted here or R-devel. Things do change, but every time we have had a formal test, Opterons were considerably better than Xeons on performance/£. [BTW, I don't think you will get a workstation motherboard that takes 32Gb of RAM (although things change fast): my own machine has a server motherboard in a small tower case.] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ 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 commented, minimal, self-contained, reproducible code.
Re: [R] RODBC on linux
On Wed, 26 Jul 2006, Marc Schwartz wrote: On Wed, 2006-07-26 at 17:52 -0400, Armstrong, Whit wrote: Anyone out there using Linux RODBC and unixODBC to connect to a Microsoft SQL server? If possible can someone post a sample .odbc.ini file? I saw a few discussions on the archives a few years ago, but no config file details were available. Thanks, Whit Whit, Do you have a Linux ODBC driver for SQL Server? unixODBC is simply the driver manager, not the driver itself. MS does not offer (not surprisingly) an ODBC driver for Unix/Linux. There are resources available however and these might be helpful: http://www.sommarskog.se/mssql/unix.html Note that Easysoft provides (at a cost) an ODBC-ODBC bridge for Unix/Linux platforms which supports ODBC connections to SQL Server: http://www.easysoft.com/products/data_access/odbc_odbc_bridge/index.html Several people have successfully used that, from the earliest days of RODBC: I believe it was part of Michael Lapsley's motivation to write RODBC. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] how to skip certain rows when reading data
On Thu, 27 Jul 2006, [EMAIL PROTECTED] wrote: Dear all, I am reading the data using read.table. However, there are a few rows I want to skip. How can I do that in an easy way? Suppose I know the row number that I want to skip. Thanks so much! The easy way is to read the whole data frame and using indexing (see `An Introduction to R') to remove the rows you do not want to retain. E.g. to remove rows 17 and 137 mydf - read.table(...)[-c(17, 137), ] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] HTTP User-Agent header
What OS is this? If Windows, see the rw-FAQ Q2.19. Otherwise, see ?download.file and choose a different download method, or look at the source code (src/modules/internet/nanohttp.c) and submit a patch. On Fri, 28 Jul 2006, James P. Howard, II wrote: I am using R in an environment where the HTTP proxy server blocks browsers that do not send User-Agent strings. Given how incredibly easy they are to fake, why? Through some testing, we have determined that R, by default (2.3.1) does not send a string when performing the chooseCRANmirror() function. Is there a setting BTW, the chooseCRANmirror() function does not do HTTP: download.file() and url() do and the help is at ?download.file. that allows us to manually set the User-Agent value? Thank you, James -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Running R on a 64 bit processor
Be careful not to use clock speed as a measure of computer performance. Pentium 4s (and the comparable Xeons) were intended to be run very fast, but never managed it. So a 2.4GHz P4 proved to be slower than a 1GHz PIII. Unless you are running Windows 64, the chip having some 64-bit instructions is irrelevant, and even if you were it is irrelevant to binary builds of R for Windows (which will actually access less memory than is possible under 32-bit Windows XP). R runs large tasks much better under Linux, and there having a 64-bit CPU and 64-bit OS pay off once you have 2Gb or more of RAM. On Fri, 28 Jul 2006, Lewis G Coggins wrote: Greetings, We recently obtained a new computer in our lab with a Pentium 4 3.86 GHz processor and 4 gb of ram running windows xp with service pack 2. After installing R on this machine, I ran a bit of code and found that the execution time was actually significantly slower than a machine running windows xp with an older Pentium chip 1.73 GHz and 1 gb of ram. After speaking with the manufacturer of the new machine, I am told that the processor in the new machine is 64 bit whereas I believe the processor in the old machine is 32 bit. I have tried to sort through the documentation on the CRAN page relative to performance of R under the 32 vs 64 bit sub architecture, however, I am no computer genius and find some of this stuff extremely confusing. Well, it is under the Unix/Linux section, and you are running Windows so it does not apply to you. In a CRAN document entitled Installation and Administration , there is reference to sub architecture... it reads: 8.1 Windows Currently the Windows build of R is a 32-bit executable. This runs happily on Windows 64 on AMD64 and EM64T, but is limited to (we are told) a 2GB address space. It will not be possible to build a native version for Windows 64 until suitable compilers are available, and currently (mid-2006) that is not in prospect. So my question is: are there any options to allow R to take advantage of the faster chip, (with 64 bit architecture), and more ram. I see in the documentation that a linux version of R may be able to take advantage of this chip... is that true what would be involved in making that work? Are there other options? As we are beginning to use R more and more around here, we may send this computer back and get a celeron 3.2 GHz chip that has 32 bit architecture... is this an intelligent choice? Thanks in advance for considering my question, Lew Coggins [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Non-interpreted strings
On Thu, 27 Jul 2006, [EMAIL PROTECTED] wrote: I am new to R, so please forgive me if there is an obvious answer to this question. I have done fairly extensive searching through R docs, google and a few R users and have not found an answer to my question. Is there a way to create a non-interpreted string object in R? For example, I am using R in a MS Windows environment and I would like to paste DOS paths into some R command: setwd(c:\some\directory) Obviously this does not work because of the escaping mechanism. And I know the obvious answer, use \\. But if you do a lot of pasting into R it could get tedious manually editing escape sequences. Why manually edit? You can do this many ways, including with R (reading from a file or from a separate line). E.g. setwd(readline(new dir: )) new dir: c:\TEMP getwd() [1] c:/TEMP I did find a workable solution to this particular problem: setwd(choose.dir())EnterPasteEnter This saves me from having to do the editing myself. I can conceive of other examples of wanting to paste other more abstract stings into R that may happen to have a \ in it. And now, thanks to choose.dir(), I have a way to do the translation automagically but... My question is, is there any way in R to not interpret the string and store the string as is? For instance, Perl allows you to do interpreted ( ) and non-interpreted strings (' '). This does not work in R; ' ' acts just like and my testing indicates that the interpretation is done at parse time. Is there any language level construct for creating a non-interpreted string in R? No. [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. [Please do, not send HTML code and BTW the answer is in the recent list archives.] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Please HELP: Problem with BUILD command
As we have said to you before, we need a reproducible example, and it is very likely that you are speculating. There is no 'BUILD' command in R: do you mean 'R CMD build'? If so, that does not parse any `R program'. On Mon, 31 Jul 2006, Zajd, John wrote: Greetings, I am unable to successfully BUILD due to a file that apears to be too long. I know it it due to the length of a particular R program because if I remove a line, even a comment line, from the file it then successfully builds. However, if I add the line back in, the build fails. The file is only 14Kb long. Any help or suggestions are greatly appreciated. Thank you for your time. John Zajd Constella Group Raleigh, NC 919 313-7746 [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] glmmNQ
On Mon, 31 Jul 2006, Maria Salomé Esteves Cabral wrote: Hi! Can anyone let me know where is the function glmmNQ? It's said that it is in the MASS library but I can not find it. Where is it said to be in the MASS *package*? Not in MASS the book, for sure. The function of that name used in MASS the book has never been made available for use with R. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Monospaced fonts in legends
On Mon, 31 Jul 2006, Erich Neuwirth wrote: Is there a way of using monospaced fonts in legends in a plot, but still using standard proportionally spaced fonts for all the titles? Yes, just use the family= argument as appropriate, e.g. par(family=mono) before calling legend. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Sweave error in example code
On Mon, 31 Jul 2006, Sundar Dorai-Raj wrote: LL wrote: Hi.. I am running R version 2.3.1 on a Windows XP machine with the latest Miktex 2.5 installed. I get no errors from R when running the Sweave example, testfile - system.file(Sweave, Sweave-test-1.Rnw, package = utils) However, when I tex the resulting .tex file (after installing a4.sty) I get the error below. This is pdfeTeX, Version 3.141592-1.30.6-2.2 (MiKTeX 2.5 RC 1) entering extended mode (Sweave-test-1.tex LaTeX2e 2005/12/01 Babel v3.8g and hyphenation patterns for english, dumylang, nohyphenation, ge rman, ngerman, french, loaded. (C:\Program Files\MiKTeX 2.5\tex\latex\base\article.cls Document Class: article 2005/09/16 v1.4f Standard LaTeX document class (C:\Program Files\MiKTeX 2.5\tex\latex\base\size10.clo)) (C:\Program Files\MiKTeX 2.5\tex\latex\ltxmisc\a4wide.sty (C:\Program Files\MiKTeX 2.5\tex\latex\ntgclass\a4.sty)) ! Missing \endcsname inserted. to be read again \protect l.11 \begin {document} ? [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. This works for me. However, when I ran this, MiKTeX prompted me to install the ntgclass package, which I did. Everything ran smoothly after that. I'm using R-2.3.1 with MiKTeX 2.4 in WinXP Pro. But he is using MiKTeX 2.5: looks like a problem with MiKTeX, as the latex error is in the initial processing. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] help on fitting negative binomial distribution with MLE
This is a special case of MASS::fitdistr MASS::glm.nb and the first will be easiest for you. On Tue, 1 Aug 2006, zhijie zhang wrote: Dear friends, Anybody knows how to fit the negative binomial distribution with MLE using R or other software? I can't find the solution, any suggestions or help would be greatly appreciated. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] open DLL in R
On Tue, 1 Aug 2006, qian li wrote: I have downloaded a DLL file. I want to look at the contents in the DLL file. How can I do it in R? You need a disassembler such as VC++'s DUMPBIN, but looking at compiled code you did not write is not an easy task. (Or objdump from the MinGW toolset.) If only you want to know what entry points it exports, use pedump -e for the pedump.exe in tools.zip (see the R-admin manual). What has this to do with R? Thanks, QL - [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] libRmath
On Wed, 2 Aug 2006, TAN Chong Hui wrote: Hi I'm trying to use the standalone library libRmath. According to the documentation, I need to builld it in src/nmath/standalone But this directory does not exist in the R I installed. What's the problem here, anyone? Did you install a *source* version of R: you are reading documentation about the sources of R? Thanks! Rgds Chong Hui [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] R an AIX
Did you look in config.log for more information about the error? It looks like you cannot even run your compiler. (This is not really an R question, and off-topic for R-help: see the posting guide.) On Tue, 1 Aug 2006, kamil Marcinkowski wrote: Hello All, I am having trouble with installing the latest R on AIX 5.3, I can't even configure. checking how to get verbose linking output from /usr/vac/bin/ xlf_r... configure: WARNING: compilation failed checking for Fortran libraries of /usr/vac/bin/xlf_r... checking how to get verbose linking output from /usr/vac/bin/ xlc_r... -v checking for C libraries of /usr/vac/bin/xlc_r... -L/usr/vac/lib - lxlopt -L/usr/lib/threads -lpthreads checking for dummy main to link with Fortran libraries... none checking for Fortran name-mangling scheme... configure: error: cannot compile a simple Fortran program Has anyone installed R-2.3.1 on AIX 5.3 using the native complier (xlc_r)? If so would you send which flags and options did you use? Thanks, Kamil Kamil Marcinkowski Westgrid System Administrator [EMAIL PROTECTED] University of Alberta site Tel.780 492-0354 Research Computing Support Fax.780 492-1729 Academic ICT Edmonton, Alberta, CANADAUniversity of Alberta This communication is intended for the use of the recipient to which it is addressed, and may contain confidential, personal, and/or privileged information. Please contact us immediately if you are not the intended recipient of this communication. If you are not the intended recipient of this communication, do not copy, distribute, or take action on it. Any communication received in error, or subsequent reply, should be deleted or destroyed. [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] open DLL in R
On Wed, 2 Aug 2006, [EMAIL PROTECTED] wrote: Hello Sir, I am just wondering that pedump is a command of 'R' because in could not It is not, as I stated. find in the 'R' help using help.search(pedump). I am requesting you to narrate as i also have to look into .dll(s). Is there any way to know what are the exported functions and constants and imported functions and constants in a easy way. Yes, see the R-admin manual, using non-R tools. thanks -gaurav. Prof Brian Ripley [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] 01-08-06 11:18 PM To qian li [EMAIL PROTECTED] cc r-help@stat.math.ethz.ch Subject Re: [R] open DLL in R On Tue, 1 Aug 2006, qian li wrote: I have downloaded a DLL file. I want to look at the contents in the DLL file. How can I do it in R? You need a disassembler such as VC++'s DUMPBIN, but looking at compiled code you did not write is not an easy task. (Or objdump from the MinGW toolset.) If only you want to know what entry points it exports, use pedump -e for the pedump.exe in tools.zip (see the R-admin manual). What has this to do with R? Thanks, QL - [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Support vector in lcrabs example
The examples in the book were run in 2001, using S-PLUS (as it says). The R package e1071 has changed since then, and hence the results it gives have changed. However, the S-PLUS version (which has not been updated) still gives the results in the book. The `problem' is your expectation that R in 2006 is identical to S-PLUS in 2001. On Wed, 2 Aug 2006, G.C. McGuinness wrote: Can anyone explain the root of my problem? When I type the following code into R, I receive 42 support vectors insted of the 21 stated in the book 'Modern Applied Statistics with S': library(MASS); library(e1071); library(class); lcrabs - log(crabs[,4:8]); (svm(crabs$sp ~ ., data = lcrabs, cost = 100, gamma = 1)); By changing the value of gamma I can obtain only 21 support vectors, but I not sure where an explanation to my problem can be found. I use R 2.3.2 and the most recent version of the package 'e1071'. My goal is to minimise the number of SVs for a separate data set. There is no `R 2.3.2'. Many thanks, Graeme. __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Summary method needed?
On Wed, 2 Aug 2006, Christian Hennig wrote: Hi list, I'm updating my fpc package at the moment and will add some new functions. I learned that there should be print and summary methods for the key functions. for 'classes', I think. The purpose of the summary methods seems to be to reduce the possibly incredibly complex information in the function's output and the print method (print.summary.foo) should print an overview of the result. Normally, summary() gives more information than print() would give for a non-data object, often by manipulations on the object. Now, the White Book said that summary produces `a synopsis of an object', but that does not seem to be the practice for model-fitting classes even in the White Book (but it is for data objects). But in some cases the print method will make use of more or less all the output information of the function. Is there any reason to implement a summary method in these cases? Would a more concise print() method be useful? If so the existing print() could become summary(). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Summary method needed?
On Wed, 2 Aug 2006, Christian Hennig wrote: Thank you Brian! I'm updating my fpc package at the moment and will add some new functions. I learned that there should be print and summary methods for the key functions. for 'classes', I think. Yes. But in some cases the print method will make use of more or less all the output information of the function. Is there any reason to implement a summary method in these cases? Would a more concise print() method be useful? If so the existing print() could become summary(). :-) What I initially did some years ago was to write summary methods to print out the required informations. Then M. Maechler told me that this is not the purpose of a summary method and I should write a print.summary method for this. Now I realise that I actually just want to print, and I don't really need the extra synopsis to be done by summary(). Now is there any recommendation on this? My intuition would be to write a print, but not a summary method. That sounds fine for your purposes. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] From 2.2.1 to 2.3
On Wed, 2 Aug 2006, [EMAIL PROTECTED] wrote: Hello everyone. Currently I am running R 2.2.1 (windows), and I will like to update to 2.3. I wanted to ask if it is possible to update without having to removed 2.2.1; or do I first need to delete 2.2.1? There is no such version as `2.3', as the posting guide points out. Updating is discussed in detail the rw-FAQ, to which the posting guide referred you. Thank you very much. Tony [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. PLEASE do! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] question about dll crashing R
On Thu, 3 Aug 2006, Thomas Lumley wrote: On Thu, 3 Aug 2006, Benn Fine wrote: I have ported some R code to C to make it faster. I can perform .Call(foobar,) once and it works fine. Absolutely correct answer. If I put a loop inside foobar and run the main code routine more than 100 times, it crashes R. Or if I call .Call(foobar) seperately more than two tims it crashes R. snip SEXP mvntest (SEXP mean, SEXP cov, SEXP temp) { int nrx , ncx , nry , ncy ,info,mode; SEXP xdims , ydims , ans; int i,j, one=1; info = 1; xdims = getAttrib (mean , R_DimSymbol ) ; ydims = getAttrib (cov , R_DimSymbol ) ; mode = REALSXP; nrx = INTEGER( xdims ) [ 0 ] ; ncx = INTEGER( xdims ) [ 1 ] ; nry = INTEGER( ydims ) [ 0 ] ; ncy = INTEGER( ydims ) [ 1 ] ; /* create the upper trianglular matrix A */ /* such that t(A) %*% A = Sigma */ GetRNGstate(); F77_CALL(dpofa) ( REAL( cov ), nry , ncy , info); Rprintf(Info = %d\n,info); for(i=0;inry;i++) for(j=0;ji;j++) REAL(cov)[i+j*ncy] = 0.0; PROTECT( ans = allocMatrix (mode, nrx , one ) ) ; for(i=0;inry;i++) REAL(temp)[i] = rnorm(0,1); ans = tmatrixprod(cov,temp); ^ Here you are returning a new SEXP from tmatrixprod but not protecting it. Remember, PROTECT() operates on the *value* of its argument, so it protects the thing that ans points to. When ans points to a new thing, it is still the old thing that is protected. and the old value of 'ans' is never used. for(i=0;inry;i++) REAL(ans)[i] = REAL(ans)[i]+REAL(mean)[i]; UNPROTECT( 1 ) ; PutRNGstate(); return( ans ) ; but the next two lines do not do any allocations. However, PutRNGstate does, so you need to UNPROTECT *after* that call. While we are at it, REAL(ans) is a function call, and you will do better to assign the value once outside the loop. I have a feeling I am messing up memory usage somewhere but haven't a clue. Do I need to do garbage collecting inside the C program ?The fact that the code runs a few times before R crashes is driving me nuts. I send most of what I need into the C routine from R, so I am not creating that many SEXP objects within the program. Any hints or ideas ? See the debugging sections in `Writing R Extensions'. Using gctorture(TRUE) and valgrind (if possible) will find these things faster. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] User input from keyboard
On Fri, 4 Aug 2006, Petr Pikal wrote: Hi cat(\n,Enter x,\n) # prompt y-scan(n=1) prompts for user imput and scans 1 line from console. (that scans one number: use readLines(n=1) to get a string). But readline() is probably easier. HTH Petr On 4 Aug 2006 at 17:06, chiya sharma wrote: Date sent:Fri, 4 Aug 2006 17:06:38 +0530 From: chiya sharma [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] User input from keyboard Dear All, Can anybody tell me the syntax for User input from keyboard in R. I mean to say that if I run the program it should ask Please enter the date at the begining of the program. I am using R-2.2.1 for windows. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] meta characters in file path
On Fri, 4 Aug 2006, Li,Qinghong,ST.LOUIS,Molecular Biology wrote: Thanks. I tried them, it works for most of those characters except * and ?. Those are not valid characters in Windows file paths (/ * : ? \ | are invalid in file or dir names). Does regular expression work in file names in windows? No, and I think you may mean wildcards (which is what work on the command line). e.g. I have a machine-generated file named 021706 matrix#1479 @50.csv, of which 1479 is kinda random. Will I be able to match 1479 with some sort of wild card chars? Yes, use dir(), with regexp pattern patching to find the name(s) you want. glob2rx() might be useful here. Thanks Johnny -Original Message- From: Tony Plate [mailto:[EMAIL PROTECTED] Sent: Thursday, August 03, 2006 3:42 PM To: Li,Qinghong,ST.LOUIS,Molecular Biology Cc: r-help@stat.math.ethz.ch Subject: Re: [R] meta characters in file path What is the problem you are having? Seems to work fine for me running under Windows2000: write.table(data.frame(a=1:3,b=4:6), file=@# x.csv, sep=,) read.csv(file=@# x.csv) a b 1 1 4 2 2 5 3 3 6 sessionInfo() Version 2.3.1 (2006-06-01) i386-pc-mingw32 attached base packages: [1] methods stats graphics grDevices utils datasets [7] base other attached packages: XML 0.99-8 Li,Qinghong,ST.LOUIS,Molecular Biology wrote: Hi, I need to read in some files. The file names contain come meta characters such as @, #, and white spaces etc, In read.csv, file= option, is there any way that one can make the function to recognize a file path with those characters? Thanks Johnny [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Error when loading odesolve
Looking at odesolve, src/Makevars is PKG_LIBS=$(BLAS_LIBS) Now, the documentation says that if you have $(BLAS_LIBS) you must also have $(FLIBS), so please change this to PKG_LIBS=$(BLAS_LIBS) $(FLIBS) and take this up with the package maintainer (which is what the posting guide asked you to do in the first place). On Sat, 5 Aug 2006, Wuming Gong wrote: Dear list, I installed odesolve package (0.5-15) in R 2.3.1 in a Solaris server (Generic_118558-11 sun4u sparc SUNW,Sun-Blade-1000). The installing progress completed without errors, though several warnings like Warning: Option -fPIC passed to ld, if ld is invoked, ignored otherwise were outputed. However, when loading the odesolve package by library(odesolve), following error messages pop out: library(odesolve) Error in dyn.load(x, as.logical(local), as.logical(now)) : unable to load shared library '/project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so': ld.so.1: R: fatal: relocation error: file /project/scratch/ligroup/R1/lib/R/library/odesolve/libs/odesolve.so: symbol __f90_ssfw: referenced symbol not found Error: package/namespace load failed for 'odesolve' Could any one tell me how to fix this problem? Thanks very much. Wuming __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] expression() - Superscript in y-axis, keeping line break in string
On Fri, 4 Aug 2006, Marc Schwartz (via MN) wrote: On Fri, 2006-08-04 at 09:47 -0600, Andrew Kniss wrote: I've tried several different ways to accomplish this, but as yet to no avail. My y-axis for a plot has a rather long label, and thus I have been using /n to break it into two lines. However, to make it technically correct for publication, I also need to use superscript in the label. For example: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=14C-glyphosate line1\n line2) will provide the text in two lines as I would like it. However, I am trying to keep those same line breaks when using expression() to get my superscript number. This will not work, as it aligns the 14C section with the bottom line of the expression making little sense to the reader. par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab=expression( ^14*C*-glyphosate line1\n line2)) Is there a way to align the 14C portion of the expression with the top line of the string rather than the bottom line? Any suggestions are greatly appreciated. Andrew plotmath, as has been covered many times previously, does not support multi-line expressions. A note should probably be added to ?plotmath on this. I've added a note. I think what is exact is that control chars are not interpreted ('expresssion' is an overloaded work in this context). Thanks for the nudge (and please do continue to make such remarks). Brian Thus, you need to create each line in the label separately: par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1) plot(1:10, ylab = ) # Now use mtext() to place each line of the y axis label mtext(2, text = expression( ^14*C*-glyphosate line1), line = 3) mtext(2, text = line2, line = 2) See ?mtext for more information. HTH, Marc Schwartz __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Postscript fonts
On Sat, 5 Aug 2006, Erich Neuwirth wrote: How can I find out what fonts are available for par(family= for the postscript device? This is dynamic: for the current value names(postscriptFonts()) [1] serifsans mono [4] symbol AvantGarde Bookman [7] Courier HelveticaHelvetica-Narrow [10] NewCenturySchoolbook Palatino Times [13] URWGothicURWBookman NimbusMon [16] NimbusSanURWHelvetica NimbusSanCond [19] CenturySch URWPalladio NimbusRom [22] URWTimes ComputerModern ComputerModernItalic [25] Japan1 Japan1HeiMin Japan1GothicBBB [28] Japan1Ryumin Korea1 Korea1deb [31] CNS1 GB1 and for more details see the current R-News (6/2). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] AIC for lognormal model
On Sat, 5 Aug 2006, Andreas Beyerlein wrote: Dear all, I want to compare some different models for a dataset by QQ plots and AIC. I get the following AICs: - linear model: 19759.66 - GAMLSS model: 18702.7 - linear model with lognormal response: -7862.182 The QQ plots show that the lognormal model fits better than the linear model, but still much worse than the GAMLSS. So, in my opinion, the AIC of the lognormal model should be between the AICs of the both other models. What happens here? Btw: For the lognormal model, I transformed the response variable by log(). Apart from that, I used the same formula as for the linear model. So you got the AIC for the logged data, which is not comparable to the others. You need to convert to a likelihood and hence AIC for the original data. (I think anyone using AIC needs to know how to do that, as it is part of the basic understanding of what a likelihood is. It is also part of the derivation of the estimation of the Box-Cox transformation, something which you might well want to consider here.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Kmeans - how to display results
There are worked examples in MASS (the book, see the FAQ). On Sat, 5 Aug 2006, Ffenics wrote: I'm very new as regards to R. I have managed to work out how to use dist and kmeans but am now wondering how best to display the results from kmeans in a graphical form. If anyone has any general advice/tips, I would be most grateful. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] paired t-test. Need to rearrange data?
On Sun, 6 Aug 2006, Henrik Parn wrote: Dear all, I have received some data arranged like this: # original data id - rep(letters[1:6], each=2) time - as.factor(rep(1:2, 6)) y - as.vector(replicate(6, c(rnorm(n=1, mean=1), rnorm(n=1, mean=2 test.data - data.frame(id, time, y) test.data I would like to perform a paired t-test of the y-values at time=1 against those at time=2, with samples paired by their id. Is it necessary to arrange the data in a format like this: # rearranged data id - letters[1:6] y1 - replicate(6, rnorm(n=1, mean=1)) # y-value at time = 1 Really, rnorm(6, 1) suffices here. y2 - replicate(6, rnorm(n=1, mean=2)) # y-value at time = 2 test.data2 - data.frame(id, y1, y2) test.data2 ...in order to perform a paired t-test? t.test(y1, y2, paired=T) If yes, which is the most convenient way to rearrange the data? Or is it possible to apply the paired t-test function to the original data set? t.test(y ~ time, test.data, paired=TRUE) And a side question: In my examples, I suppose can I use set.seed to reproduce the 'rnorm-values' created in the 'original data' also in my the 'rearranged data'. Can someone give me a hint of how to apply the same 'seed' to all the rnorms? Using the same seed will give identical values from rnorm, surely not what you want. You need to generate the rnorms in the same order, that is all. matrix(rnorm(12) + c(1,2), 6, 2, byrow=TRUE) will do the trick. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Source installation error: gfortran and gcc disagree on int and double ...
First, you do not need -fPIC: it is the same as -fpic which R selects on your platform. Second, please look at config.log to find the exact problem: it well be that your compilers are not properly installed (as was the case in the reference you quote below). Finally, your compilers are pretty obselete (there have been 4.0.2, 4.0.3, 4.1.0 and 4.1.1), so you should be updating them. On Sun, 6 Aug 2006, Mike wrote: ... configure: error: Maybe change CFLAGS or FFLAGS? Dear list, This problem has been posted before (http://finzi.psych.upenn.edu/R/Rhelp02a/archive/7982.html), That was over three years ago, for R 1.6.0 on Solaris, so I am not sure why you thought it would help. but suggestions did not help. My machine: AMD Duron 800 MHz, MandrivaLinux 10.2, gcc (and gfortran): 4.0.1, R source: 2.3.1. I had to set CPICFLAGS and FPICFLAGS to -fPIC. I tried ./configure with default CFLAGS and FFLAGS flags and with -O3 -g with the same error message. How can I pass the error? Thank you in advance, Mike. __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Backquote in R syntax
?Quote tells you all about quotes in R (and so does ?backquote in R-devel, but many people call it backtick and that is all 2.3.1 has). On Mon, 7 Aug 2006, [EMAIL PROTECTED] wrote: Hi Folks, Can someone satisfy my curiosity (well, at least about the following query!) Reading the draft proofs of an article I've been asked to look through, I find the typesetter has set what would normally be entered as source(xyz.R) or source('xyz.R') as source(`xyz.R') i.e. it has come out with an opening backquote, then xyz.R, then a closing forward quote. I suspect the intervention of intelligent software (Ã la Word's clever quotes). Well, the cure is clear and I'm not asking about that. But I got curious about what role the backquote might play in R syntax (if any). As a start I tried typing that in as it stands: source(`xyz.R') ## and then you get the continuation + as if it were ## incomplete, so I tried a closing parenthesis: + ) Error: unprotect_ptr: pointer not found So it wasn't a mere syntax error (which would have caused an error message saying just that) -- using the backquote caused R to try to do something. So now I'm wondering what the effect of ` is, in R. Statutory Declaration: I have performed an R Site Search for backquote obtaining 9 hits none of which seems to address this question. Best wishes to all, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 07-Aug-06 Time: 10:25:31 -- XFMail -- __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ 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 commented, minimal, self-contained, reproducible code.
Re: [R] CPU Usage with R 2.1.0 in Windows (and with R 2.3.1)
On Mon, 7 Aug 2006, Singu wrote: You could compile R using specific libraries if threading/dual core is the issue Look eg here: http://tolstoy.newcastle.edu.au/R/devel/05/12/3355.html Hmm, quoting me. None of those libraries for Windows is multithreaded, nor does it say anthing about threads for Windows. and in R Administration Guide Section A.(2.2) . And probably you are better of with Linux if you rely on speed: http://www.r-project.org/useR-2006/Slides/IacusEtAl.pdf Stefan PS For Windows the precompiled Atlas Rblas.dll seems to be single-threaded. I use it on my P4 3Ghz HT Processor and CPU usage is at 50% as well. Yes, as Windows does not have pthreads which is what ATLAS would use. Markus Preisetanz schrieb: ... I have exactly the same issue with R 2.3.1 . The Question is: Why is R unable to take more CPU space to make the calculation process go faster? In my case no hardisk nor any network device is involved (data in RAM, 600 of 1024 MB filled) - and the CPU usage of the rgui-process does not exceed 50%. Has anybody an idea? Is there a setting a can change? Sincerely, Markus Markus Preisetanz Consultant Client Vela GmbH Albert-Roßhaupter-Str. 32 81369 München fon: +49 (89) 74217-113 main: +49 (89) 74217-150 fax: +49 (89) 74217-250 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] http://www.clientvela.com http://www.clientvela.com/ Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received the e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden xx From: Doran, Harold HDoran_at_air.org mailto:HDoran_at_air.org?Subject=Re:%20%5BR%5D%20CPU%20Usage%20with%20R%202.1.0%20in%20Windows Date: Wed 20 Jul 2005 - 04:59:34 EST Dear Michael: Why is it a problem that R is not using more CPU space than it seems to need? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greene, Michael Sent: Tuesday, July 19, 2005 2:29 PM To: '[EMAIL PROTECTED]' Subject: [R] CPU Usage with R 2.1.0 in Windows Hi, I'm using a fairly simple HP Compaq desktop PC running Windows 2K. When running a large process in R, the process RGUI.exe will never exceed 50% of the CPU usage. The program used to be able to use more of the computer, but does not now. I don't believe this is a multiple processor machine. Can anyone give any advice on how to solve the problem? Thanks, Michael Greene Product Management Plymouth Rock Assurance Corp 617-951-1682 [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Capturing stderr from system()
On Mon, 7 Aug 2006, McGehee, Robert wrote: Hello, I have a system command that occasionally fails and writes output to standard error, which R will print to the screen when ignore.stderr = FALSE. No, R does not print to the screen, your shell does. You can capture shell and command errors by system(command 21, intern=TRUE) or whatever the appropriate syntax for your shell is. E.g. system(BadCommand 21, intern=TRUE) [1] sh: BadCommand: command not found For example: system(BadCommand) sh: line 1: BadCommand: command not found (My shell does not give `line 1' here.) I would like to know if the above command fails, and can presumably do this by parsing the stderr message that R prints to the screen. My (hopefully simple) problem is that I can't figure out how to capture this output. You are starting from a false assertion [...] PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. PLEASE do note what it says about where to send programming questions. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Source installation error: gfortran and gcc disagree on int and double ...
First, you replied to the list and not to me, which was discourteous. Your error does indeed appear to be an incorrectly installed compiler. conftestf.o: In function `cftest_': /home/mike/Desktop/R-2.3.1/conftestf.f:9: undefined reference to `_gfortran_pow_r8_i4' this is in -lgfortran, so that is not being found or is broken. One possibility is a missing symlink that is in a -devel RPM. This is not an R issue. On Mon, 7 Aug 2006, Mike wrote: Prof Brian Ripley wrote: First, you do not need -fPIC: it is the same as -fpic which R selects on your platform. Right, I commented the flags and configure goes just as far Second, please look at config.log to find the exact problem: it well be that your compilers are not properly installed (as was the case in the reference you quote below). from config.log it seem that there are a few missing inclides and syntax errors in confdefs.h. (I can quote the specifics, if necessary). The last lines before the error message are: configure:27770: checking whether gfortran and gcc agree on int and double conftest.c: In function 'main': conftest.c:28: warning: implicit declaration of function 'printf' conftest.c:28: warning: incompatible implicit declaration of built-in function 'printf' conftest.c:29: warning: implicit declaration of function 'exit' conftest.c:29: warning: incompatible implicit declaration of built-in function 'exit' conftestf.o: In function `cftest_': /home/mike/Desktop/R-2.3.1/conftestf.f:9: undefined reference to `_gfortran_pow_r8_i4' collect2: ld returned 1 exit status configure:27848: WARNING: gfortran and gcc disagree on int and double configure:27850: error: Maybe change CFLAGS or FFLAGS? Finally, your compilers are pretty obselete (there have been 4.0.2, 4.0.3, 4.1.0 and 4.1.1), so you should be updating them. Changing compiler is not an option for me. Could you advise me how to configure the flags? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Netiquette, was Re: ... gfortran and gcc...
On Tue, 8 Aug 2006, Peter Dalgaard wrote: Prof Brian Ripley [EMAIL PROTECTED] writes: First, you replied to the list and not to me, which was discourteous. You mean that he replied to the list *only*, I hope. Yes, and it was written as if to me, and was a reply to an email from me. I usually consider it offensive when people reply to me and not the list (reasons including: It feels like being grabbed by the sleeve, I might not actually be the best source for the answer, and it's withholding the answer from the rest of the subscribers.) We do ask people to copy to the list. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] prefixing list names in print
On Tue, 8 Aug 2006, Laurent Deniau wrote: With print(list(A=a,B=b)) it displays $A [1] a $B [1] b I would like to add a common prefix to all the list tags after the $. `prefix' ... `after'? You seem to want to prefix component names: why? What do you want for component $a$b$c? For unnamed components? Pasting the prefix to the names does not work (appear after the $). For example if the prefix would be P, it should display: P$A [1] a P$B [1] b I tried to add a name attribute to the list or to add a prefix=P to print but nothing works. Any hint? You will need to alter the C code to do this. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] problem with tseries (was unable to restore saved data)
Hmm. 'time' is in package stats, and you seem to have saved an object that is pulling in the namespace 'tseries'. Loading the workspace is done before loading the standard set of packages. This appears to be a bug in tseries, for if its namespace needs 'time', it should import it from 'stats', and it is not even depending on 'stats'. I can confirm that: gannet% env R_DEFAULT_PACKAGES=NULL R ... loadNamespace(tseries) Error: object 'time' not found whilst loading namespace 'tseries' That is a matter for the 'tseries' maintainer (Cc:ed here). If you try library(tseries) at that point you find library(tseries) Loading required package: zoo Error: object 'aggregate' not found whilst loading namespace 'zoo' Error: package 'zoo' could not be loaded so package zoo has a similar problem (maintainer Cc:ed). What can you do? The simplest is to rename the workspace and load() afterwards as you have done. But before saving, remove any objects which have a dependence on tseries. On Tue, 8 Aug 2006, Alessandro Gagliardi wrote: Lately, when I try to open R I get the following error message: Error: object 'time' not found whilst loading namespace 'tseries' Fatal error: unable to restore saved data in .RData If I rename .RData to RData.RData and then try opening R again it works. Then I can load(RData.RData) without a problem. But if I try saving my workspace (as the default, .RData) and reload R it crashes all over again. R does NOT crash. It is objecting (correctly) to your saved workspace. Please see the posting guide, which specifically asked you not to abuse that word. I don't know how to get this 'time' object back. (I must have removed it by accident at some point.) Any ideas? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] How to draw the decision boundaries for LDA and Rpart object
On Wed, 9 Aug 2006, Am Stat wrote: Hello useR, Could you please tell me how to draw the decision boundaries in a scatterplot of the original data for a LDA or Rpart object. There are examples in MASS (the book). For example: library(rpart) fit.rpart - rpart(as.factor(group.id)~., data=data.frame(Data) ) How can I draw the cutting lines on the orignial Data? Or is there any built in functions that can read the rpart object 'fit.rpart' to do that? See partition.tree in package tree. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] missing documentation entries
This is discussed in `Writing R Extensions', which both points you to the 'internal' keyword, and (in the current version) mentions using name spaces to hide such functions. This really was a question for R-devel: please do study the posting guide. `R-devel is intended for questions and discussion about code development in R.' On Wed, 9 Aug 2006, Adrian Dusa wrote: Dear list, When creating a package, there are always many little utility functions that belong to the internal kitchen of the main, documented functions. Now, when checking the sources with R CMD check, I get a warning for those little functions that are not documented. I would have two questions: - is it mandatory to document _all_ functions (will the source package be rejected by CRAN if otherwise)? - if not, is there a way to tell R which are the functions that I don't want to document? Thanks, Adrian -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Error message when using optim
(Subject changed to something less perjorative. This is not `optim error'.) On Wed, 9 Aug 2006, Frank Black wrote: Dear all, There have been one or two questions posted to the list regarding the optim error non-finite finite-difference value [4]. The error apparently means that the 4th element of the gradient is non-finite. (Without an example of the optim usage, we have little to go on. This does not occur in the default method, so we don't even know which method was asked for. Please do study the posting guide: we ask to information for good reasons.) It means that the finite-difference approximation to the gradient is non-finite (as it says). Most likely this occurs when the user-supplied function is returning Inf (so the finite difference is Inf - Inf) or returning NA/NaN. My question is what part(s) of my program should I fiddle with in an attempt to fix it? Starting values? Something in the log-likelihood itself? Perhaps the data (which is generated)? Any thoughts would be greatly appreciated. If the function you are optimizing never returns Inf or NA/NaN, the message will not occur. Nor will it occur if you supply a gradient function. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] How to draw the decision boundaries for LDA and Rpart object
On Wed, 9 Aug 2006, Am Stat wrote: Dr. Ripley, R-help is not the address of `Dr. Ripley', nor even that of the person who wrote to you. Thanks very much for your help. I have used your partition tree and it works well. I am not familiar with the 'tree' package but I found that the threshold to make a cut returned by tree and rpart is almost the same value. Does that mean the decision boundaries for Rpart and Tree are the same for a same data when using the default value of parameters, no matter what the structure of data is? No, they can differ. There are comparisons in MASS (the book). Thanks very much! Leon - Original Message - From: Prof Brian Ripley [EMAIL PROTECTED] To: Am Stat [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Sent: Wednesday, August 09, 2006 3:04 AM Subject: Re: [R] How to draw the decision boundaries for LDA and Rpart object On Wed, 9 Aug 2006, Am Stat wrote: Hello useR, Could you please tell me how to draw the decision boundaries in a scatterplot of the original data for a LDA or Rpart object. There are examples in MASS (the book). For example: library(rpart) fit.rpart - rpart(as.factor(group.id)~., data=data.frame(Data) ) How can I draw the cutting lines on the orignial Data? Or is there any built in functions that can read the rpart object 'fit.rpart' to do that? See partition.tree in package tree. PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] decimal accuracy in pnorm( )
On Thu, 10 Aug 2006, Chronopoulos Dimitris wrote: Dear R users Is there any way to increase the decimal accuracy for the normal probability distribution? When one needs an accurate p-value for instance this is provided by pnorm(10,lower.tail=F) [1] 7.619853e-24 However, what happens when instead of a P[Xx], a more accurate P[X=x] is the objective. That is P[X=x] ! If you meant that pnorm(10,lower.tail=TRUE) [1] 1 then the problem is your computer, which has no representable numbers between 1-1e-16 and 1, and so correctly chose the nearest representable number. A basic understanding of numerical methods is necessary to do statistical calculations accurately: perhaps your university offers courses in the area? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] extractAIC using surf.ls
Roger, thank you for looking into this. However, the posting guide asked the poster to contact the maintainer. Had (s)he done so, I would have pointed out that spatial 7.28-2 (the current version for R-devel) has this corrected (in a slightly simpler way). On Thu, 10 Aug 2006, Roger Bivand wrote: Yan Wong h.y.wong at leeds.ac.uk writes: Although the 'spatial' documentation doesn't mention that extractAIC works, it does seem to give an output. Could I suggest moving this question to the R-sig-geo list? Please note that surf.ls() converts x and y to the [-1, +1] range to ensure that higher powers of possibly very large absolute coordinate values do not cause trouble, so that the surf.ls() and lm() models may differ anyway. I believe that there is a bug in extractAIC.trls() - which I contributed to the spatial package some years ago, with edf - df.residual.trls(fit) rather than n - df.residual.trls(fit). When this is corrected, for this case, the extractAIC() results agree. Roger Bivand I may have misunderstood, but shouldn't the following give at least the same d.f.? library(spatial) data(topo, package=MASS) extractAIC(surf.ls(2, topo)) [1] 46. 437.5059 extractAIC(lm(z ~ x+I(x^2)+y+I(y^2)+x:y, topo)) [1] 6. 357.5059 # and if the AIC values differ, shouldn't they do so by an additive constant? (extractAIC(surf.ls(2, topo))-extractAIC(lm(z ~ x+I(x^2)+y+I(y^2) +x:y, topo)))[2] [1] 80 (extractAIC(surf.ls(1, topo))-extractAIC(lm(z ~ x+y, topo)))[2] [1] 92 # Using R 2.3.1 (OS X), spatial version 7.2-27.1 Thanks Yan -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] - factanal scores correlated?
This is a Heywood case, and you don't have a valid fit: myfac Call: factanal(x = m1, factors = 3, scores = regression) Uniquenesses: v1v2v3v4v5v6 0.005 0.101 0.005 0.224 0.084 0.005 notice no less than 3 very small uniquenesses. On Fri, 11 Aug 2006, Christian Montel wrote: Hi, I wonder why factor scores produced by factanal are correlated, and I'd appreciate any hints from people that may help me to get a deeper understanding why that's the case. By the way: I'm a psychologist used to SPSS, so that question my sound a little silly to your ears. Here's my minimal example: *** v1 - c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) v2 - c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) v3 - c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) v4 - c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) v5 - c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) v6 - c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) m1 - cbind(v1,v2,v3,v4,v5,v6) myfac - factanal(m1, factors=3, scores=regression)# cor(myfac$scores) *** Tells me Factor1 Factor2 Factor3 Factor1 1.0 0.001624383 0.002862785 Factor2 0.001624383 1.0 0.001956953 Factor3 0.002862785 0.001956953 1.0 which means that factor correlations are indeed quite low with regard to interpretation issues, but an analysis of a larger dataset yielded factor intercorrelations up to .10. I guess this is an optimization issue because a lower setting of lower tends to lower factor intercorrelations, but I'm still confused because I (misleadingly?) thought that factor scores are (completely) independent by definition? Any hints would be greatly appreciated, best regards, Christian -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] bug in interaction order when using drop?
On Thu, 10 Aug 2006, Petr Pikal wrote: Ooops, my first suggestion reorders factor itself but if (drop) factor(ans) else ans instead of whole drop construction shall preserve levels order without changing order of factor Even easier would be to return ans[,drop=drop]. It seems to me that there is an argument for expecting interaction(..., drop=TRUE) to give the same result as interaction(...)[,drop=TRUE], but little argument that any ordering is a *bug*. The order of the levels of a factor are arbitrary, and in fact they seem to me to be in a strange order, with the levels of the first factor varying fastest (reverse lexiographic order). levels(interaction(c(A, A, B), letters[1:3])) [1] A.a B.a A.b B.b A.c B.c so the existing levels(interaction(c(A, A, B), letters[1:3], drop=T)) [1] A.a A.b B.c looks more sensible in this case. Petr On 10 Aug 2006 at 16:32, Petr Pikal wrote: From: Petr Pikal [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date sent:Thu, 10 Aug 2006 16:32:54 +0200 Priority: normal Subject: [R] bug in interaction order when using drop? Hallo all version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status beta major 2 minor 3.1 year 2006 month 05 day23 svn rev38179 language R version.string Version 2.3.1 beta (2006-05-23 r38179) When I use interaction() without drop=T parameters I will get neatly organized factor with protiproud and souproud aligned. levels(interaction(vykon, teplota, proudeni)) [1] 3.750.protiproud 12.750.protiproud 3.775.protiproud 12.775.protiproud 3.800.protiproud 12.800.protiproud [7] 3.825.protiproud 12.825.protiproud 3.850.protiproud 12.850.protiproud 3.750.souproud12.750.souproud [13] 3.775.souproud12.775.souproud 3.800.souproud 12.800.souproud 3.825.souproud12.825.souproud [19] 3.850.souproud12.850.souproud However when I use levels(interaction(vykon, teplota, proudeni, drop=T)) [1] 3.775.protiproud 3.800.souproud3.750.souproud 12.850.souproud 12.825.protiproud everything is out of order. I know I can reorder any factor according to my wish but it would be good to have it ordered same way as without using drop. Everything comes from unique in if (drop) { f - unique(ans[!is.na(ans)]) ans - match(ans, f) lvs - lvs[f] } maybe it can be modified. if (drop) { f - unique(ans[!is.na(ans)]) ord - order(f) ans - match(ans, f) lvs - lvs[f[ord]] } which seems to work but I am not sure if it does not makes problems having NA in data. Here is my data frame. Thank you Petr Pikal dump(df, file=stdout()) df - structure(list(proudeni = structure(as.integer(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1)), .Label = c(protiproud, souproud), class = factor), vykon = as.integer(c(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12)), teplota = as.integer(c(775, 775, 775, 775, 775, 775, 775, 775, 775, 775, 775, 775, 775, 775,
Re: [R] anova.mlm for single model (one-way repeated measured anova)
On Sat, 12 Aug 2006, takahashi kohske wrote: Dear list members: I'd like to one-way repeated measured anova by using mlm. I'm using R-2.3.1 and my code is: dat-matrix( c(9,7,8,8,12,11,8,13, 6,5,6,3,6,7,10,9, 10,13,8,13,12,14,14,16, 9,11,13,14,16,12,15,14), ncol=4, dimname=list(s=1:8, c=1:4)) mlmfit-lm(dat~1) anova(mlmfit, X=~1) Error: ceiling(length.out) : Non-numeric argument to mathematical function this error occurs in anova.mlm if (rk 0) { p1 - 1:rk comp - object$effects[p1, ] asgn - object$assign[object$qr$pivot][p1] nmeffects - c((Intercept), attr(object$terms, term.labels)) tlabels - nmeffects[1 + unique(asgn)] ix - split(seq(length = nrow(comp)), asgn) #HERE ss - lapply(ix, function(i) crossprod(comp[i, , drop = FALSE])) df - sapply(split(asgn, asgn), length) } because nrow(comp) returns NULL. in my memory, R-2.2.* ( or may be R-2.3.0) can correctly handle this code. so, I think this is a kind of side-effect of fixing PR#8679. currently, i can workaround as follows: anova(mlmfit, update(mlmfit, ~0), X=~1) this code returns correct answer. I don't know whether this behavior is correct or bug. Yes, it is a bug. The line comp - object$effects[p1, ] should be comp - object$effects[p1, , drop=FALSE] I am changing this in 2.3.1 patched and R-devel. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Changing R network connections
Since you mention 'preferences', it seems you might be using Windows: the information you require is in the rw-FAQ. Since the posting guide asked you to state your platform and read the relevant FAQ, that is the place to start: see the footer below. On Fri, 11 Aug 2006, Alexandre Fabrice Letimier wrote: Dear all, I have some difficulties to get R to download the various packages. It seems that it's a problem of the network that I'm on. I would need to configure R so that I can put the proxy address and the port of the network that I'm on. Can anyone explain to me how to change these in R. I've looked at the preferences but couldn't find it there. Thanks a lot for you help. Regards, Fabrice Letimier -- __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Puzzling warning using 2.3.1...
On Sun, 13 Aug 2006, Brian Lunergan wrote: Greetings folks: Stepped away from a win/lin dual boot system and spent the better part of the past week resetting a windows only arrangement. Before the switch I was running 2.3.1 without any strange behaviours. When I reached the point of putting it back on the machine I would get this puzzling warning the first time I would try to select a cran mirror: chooseCRANmirror() Warning message: DLL attempted to change FPU control word from 8001f to 9001f When I pulled it off and reinstalled 2.2.1 I got no such warning. Thoughts or suggestions? This is a warning about a problem with your OS, not with R. Could the file have been damaged or corrupted in same way? The Md5sum checked out but I'm not sure how accurate an assessment that is of the file's integrity. Should I just download a new Did you run md5check?: that is very thorough. See the rw-FAQ Q2.3. copy and try again with that? Not sure if it's important but I run a Win98se setup. This is covered by rw-FAQ Q2.21 (although that will not be obvious to you, but please read it now). It indicates a problem with some *non-R* DLL on your machine, and not a problem with R itself. R 2.3.1 looks up the latest list of mirrors online (and is much more aggressively protected against rogue DLLs), and 2.2.1 did not, so my guess is that it is your winsock or other internet access DLLs. R has corrected the problem for you. Your OS have been end-of-lined by Microsoft long ago, but I do suggest you ensure it is as fully updated as possible (including Internet Explorer), assuming that using a current OS is out of the question. (R support for that OS is likely to be withdrawn in the near future: it was somewhat unexpected that 2.3.x still worked on Win98 since it uses features that were said in some accounts not to be present.) -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] left-justified fixed-width format
On Mon, 14 Aug 2006, roger bos wrote: I need to save data in fixed-width format without headers and reading the help archive leads me to believe that sprintf is pretty much the only way to do this. My question is, is there anyway to change the output so the text in each column is left justified instead of right justified? My code sample is below where comb is the data frame. TIA, Roger format can do this, easily. And for sprintf, use the '-' flag documented on the help page(!): sprintf(%22s, foo) [1]foo sprintf(%-22s, foo) [1] foo -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Attempt to access unmapped memory
On Mon, 14 Aug 2006, Alexandre Aguiar wrote: Hi, I am usiing R 2.3.1 under Linux kernel 2.6.11 with libreadline/libhistory 5.1. That is known to be buggy. Either patch it or downdate to 5.0. Bothe R and readline were compiled without quircks with gcc 3.3.3 and g77. Every time I try to edit command line by using del key the following error happens: 8-- ipacks - instaleld.packages() *** caught segfault *** address (nil), cause 'memory not mapped' Possible actions: 1: abort (with core dump) 2: normal R exit 3: exit R without saving workspace 4: exit R saving workspace Selection: Segmentation fault 8-- As I have readline 4.3 installed too, I adjusted the symlinks to point to 5.1. No problem with bash. This setup works fine in another machine with same OS and versions. Any clues? Thanks in advance. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Fast way to load multiple files
On Mon, 14 Aug 2006, Berton Gunter wrote: A reproducible example here would help (please see posting guide). A guess: is your filelist a list of (quoted) character strings? Correct pathnames to the files with correct separators for your OS? I think the issue is (from the help page) Usage: load(file, envir = parent.frame()) ^^ Arguments: file: a (readable binary) connection or a character string giving the name of the file to load. envir: the environment where the data should be loaded. and so they were not loaded into .GlobalEnv. Try lapply(filelist, load, envir=.GlobalEnv) which works for me. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Peter Eiger Sent: Monday, August 14, 2006 1:00 PM To: r-help@stat.math.ethz.ch Subject: [R] Fast way to load multiple files Hi, Instead of having to program a loop to load several workspaces in a directory, it would be nice to store the filenames in a list filelist and then to apply load to this list lapply( filelist, load) Unfortunately, although it seems that R is loading the files, the contained objects are not available in the workspace afterwards. Any hints what I'm doing wrong or how to circumvent the problem? -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] help: cannot allocate vector of length 828310236
Does it make any statistical sense to do polr or probit regression (not the same thing) on `really huge data'? There are few regression-like problems in which model inadequacy does not swamp estimation uncertainty for as few as a 1000 cases. If you want to do that sort of thing, by all means use SAS to do it. But if you are not prepared to spend a few $$ on adequate RAM, don't expect free technical consultancy, especially not from those whose work you are using and not crediting. - The uncredited author of polr(). On Mon, 14 Aug 2006, T Mu wrote: Hi all, I was trying a probit regression using polr() and got this message, polr is a strange choice of tool for 'probit regression' as the term is usually used. It does 'ordered probit regression'. Error in model.matrix.default(Terms, m, contrasts) : cannot allocate vector of length 828310236 The data is about 20M (a few days ago I asked a question about large file, thank you for responses, then I use MS Access to select those columns I would use). R is 2.3.1, Windows XP, 512M Ram. I am going to read some help on memory use in R, but hope anybody can give me some quick hints. Quick hint: read and follow the posting guide BEFORE posting. Is it because iphysical memory runs out, or some other things could be wrong with data or polr()? Does R use virtual memory? If so, what options can I set? If not, can R deal with really huge data (except adding RAM according to data size)? If this is the case, it is too bad that I have to tell my boss to go back to SAS. Now it is not a speed issue yet. Thank you. [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Protection stack overflow
R has a command-line option to set the ppstack size, --max-ppsize=NSet max size of protect stack to N Looks like you need to supply this (and it can be done with embedded R) if the problem persists with current R. You could also try arima0 or even ar to do the fitting. On Tue, 15 Aug 2006, Paul Koufalas wrote: G'day all. I'm a new user of R -- but an arms-length user, as I'm running it from Octave via the ROctave interface that Duncan Temple Lang wrote some years ago and Stephan Van Der Walt recently updated for use with Octave 2.1.71. I'm using R version 2.1.1. ROctave uses libR.so to provide the interface. My system is Ubuntu linux 5.10 and I'm using the packages that come with this distro. Note that your version of R is well outdated, and the posting guide did ask you to update it BEFORE posting. I'm getting a protection stack overflow error when recursively calculating AR(p) time series models using the arima() function. The recursion is involved because I calculate a new model with each new time series data point. (I'm trying to reproduce some results in a research paper and this is what they're doing.) I've tried setting the expressions parameter to a higher number using options(expressions=50) but I'm still getting this problem with stack overflow. I can get about 400-odd iterations and then the overflow error appears. I yet haven't tried running the recursion natively in R, and I realise I should do that. Your advice would be much appreciated. Cheers, Paul. __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] nls
You problem is x^c for x = 0. If you intended only c 1, try a starting value meeting that condition (but it seems that the optimal c is about 0.27 is you increase x slightly). Why have you used ~~ ? (Maybe because despite being asked not to, you sent HTML mail?) On Tue, 15 Aug 2006, Xiaodong Jin wrote: Is there anyway to change any y[i] value (i=2,...6) to make following NLS workable? x - c(0,5,10,15,20,25,30) y - c(1.0,0.82000,0.68000,0.64000,0.7,0.68667,0.64000) lm(1/y ~~ x) nls(1/y ~~ a+b*x^c, start=list(a=1.16122,b=0.01565,c=1), trace=TRUE) #0.0920573 : 1.16122 0.01565 1.0 #Error in numericDeriv(form[[3]], names(ind), env) : #Missing value or an infinity produced when evaluating the model - [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Aliases for arguments in a function
foo - function(arg1, this=that, that) ... works. On Tue, 15 Aug 2006, [EMAIL PROTECTED] wrote: Hi all. I have a function that I would like to use either the argument name as originally defined or another name. Within the function (and other functions) use the argument name as originally written, so I don't want to simply remove the old argument name for the new one, but simply allow the function to treat both argument names as equivalent. Here is an example: foo - function(arg1, this) { if(this 0) stop(this must be positive) return(arg1/this) } foo(arg1=5, this=10) But, I also want foo() to work equivalently with the following (where 'this' and 'that 'are treated as if they were the same): foo(arg1=5, that=10) Any thoughts would be appreciated. Thanks, Ken - [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] nls
On Tue, 15 Aug 2006, Peter Dalgaard wrote: Prof Brian Ripley [EMAIL PROTECTED] writes: You problem is x^c for x = 0. If you intended only c 1, try a starting value meeting that condition (but it seems that the optimal c is about 0.27 is you increase x slightly). Surely you mean c 0. I did. nls(1/y ~ a+b*x^exp(c), start=list(a=1.16122,b=0.01565,c=0)) Nonlinear regression model model: 1/y ~ a + b * x^exp(c) data: parent.frame() a b c 0.9944025 0.1953168 -1.1495206 residual sum-of-squares: 0.03303464 nls(1/y ~ a+b*x^c, start=list(a=1.16122,b=0.01565,c=exp(-1.1))) Nonlinear regression model model: 1/y ~ a + b * x^c data: parent.frame() a b c 0.9944026 0.1953165 0.3167891 residual sum-of-squares: 0.03303464 (but even setting c=exp(-1) triggers the error; there could be cause for robustifying the nls algorithm) Well, there is an option to use a bounded-region algorithm, e.g. x - c(0,5,10,15,20,25,30) y - c(1.0,0.82000,0.68000,0.64000,0.7,0.68667,0.64000) nls(1/y ~ a+b*x^c, start=list(a=1.16122,b=0.01565,c=1), trace=TRUE, algorithm=port, lower=c(-Inf, -Inf, 0), upper=rep(Inf, 3)) works. Why have you used ~~ ? (Maybe because despite being asked not to, you sent HTML mail?) On Tue, 15 Aug 2006, Xiaodong Jin wrote: Is there anyway to change any y[i] value (i=2,...6) to make following NLS workable? x - c(0,5,10,15,20,25,30) y - c(1.0,0.82000,0.68000,0.64000,0.7,0.68667,0.64000) lm(1/y ~~ x) nls(1/y ~~ a+b*x^c, start=list(a=1.16122,b=0.01565,c=1), trace=TRUE) #0.0920573 : 1.16122 0.01565 1.0 #Error in numericDeriv(form[[3]], names(ind), env) : #Missing value or an infinity produced when evaluating the model - [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] question re: summarry.lm and NA values
On Tue, 15 Aug 2006, Petr Pikal wrote: Hi On 15 Aug 2006 at 7:01, r user wrote: Date sent:Tue, 15 Aug 2006 07:01:13 -0700 (PDT) From: r user [EMAIL PROTECTED] To: rhelp r-help@stat.math.ethz.ch Subject: [R] question re: summarry.lm and NA values Is there a way to get the following code to include NA values where the coefficients are NA ? ((summary(reg))$coefficients) better coef(reg) coef(summary(reg)), perhaps. explanation: Using a loop, I am running regressions on several subsets of data1 . reg - ( lm(lm(data1[,1] ~., data1[,2:l])) ) My regression has 10 independent variables, and I therefore expect 11 coefficients. After each regression, I wish to save the coefficients and standard errors of the coefficients in a table with 22 columns. I successfully extract the coefficients using the following code: reg$coefficients I attempt to extract the standard errors using : aperm((summary(reg))$coefficients)[2,] ((summary(reg))$coefficients) My problem: For some of my subsets, I am missing data for one or more of the independent variables. This of course causes the coefficients and standard erros for this variable to be NA . ??%^*^?? What version? My lm behaves in accordance with na.action and it throws an error in case na.fail, computes a value in case of na.omit or na.exclude and again throws an error if the variable consist exclusively from NA values. The only way how to get NA in coeficient is when a variable is either constant or linear combination of other variable(s). Then coef(reg) will give you correctly NA in the variable which appears constant and in this case you could use it for setting standard error also as NA let say by using ifelse statement and matching of names. That happens in the print method, stats:::print.summary.lm contains coefs - x$coefficients if (!is.null(aliased - x$aliased) any(aliased)) { cn - names(aliased) coefs - matrix(NA, length(aliased), 4, dimnames = list(cn, colnames(coefs))) coefs[!aliased, ] - x$coefficients } so the code is already available Is there a way to include the NA standard errors, so that I have the same number of standard erros and coefficients for each regression, and can then store the coefficients and standard erros in my table of 22 columns? __ 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 commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] read.csv issue
Set allowEscapes = FALSE when reading. See the help page for more details. There is perhaps an argument for changing the default for allowEscapes under read.csv, especially as people have now changed that for comment.char (in R-devel). On Wed, 16 Aug 2006, Doran, Harold wrote: I'm trying to read in some data from a .csv format and have come across the following issue. Here is a simple example for replication # A sample .csv format schid,sch_name 331-802-7081,School One 464-551-7357,School Two 388-517-7627,School Three \ Four 388-517-4394,School Five Note the third line includes the \ character. However, when I read the data in I get read.csv(file.choose()) schid sch_name 1 331-802-7081School One 2 464-551-7357School Two 3 388-517-7627 School Three Four 4 388-517-4394 School Five It turns out to be very important to read in this character as I have a program that loops through a data set and Sweave's about 30,000 files. The variable sch_name gets dropped into the tex file using \Sexpr{tmp$sch_name}. However, if there is an , the latex file won't compile properly. So, what I need is for the data to be read in as schid sch_name 1 331-802-7081School One 2 464-551-7357School Two 3 388-517-7627 School Three \ Four 4 388-517-4394 School Five I am obligated by a client to include the in the school name, so eliminating that isn't an option. I thought maybe comment.char or quote would be what I needed, but they didn't resolve the issue. I'm certain I'm missing something simple, I just can't see it. Any thoughts? Harold [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] read.csv issue
On Wed, 16 Aug 2006, Prof Brian Ripley wrote: Set allowEscapes = FALSE when reading. See the help page for more details. There is perhaps an argument for changing the default for allowEscapes under read.csv, especially as people have now changed that for comment.char (in R-devel). Oops, it was already changed in 2.2.0. What version of R is this? On Wed, 16 Aug 2006, Doran, Harold wrote: I'm trying to read in some data from a .csv format and have come across the following issue. Here is a simple example for replication # A sample .csv format schid,sch_name 331-802-7081,School One 464-551-7357,School Two 388-517-7627,School Three \ Four 388-517-4394,School Five Note the third line includes the \ character. However, when I read the data in I get read.csv(file.choose()) schid sch_name 1 331-802-7081School One 2 464-551-7357School Two 3 388-517-7627 School Three Four 4 388-517-4394 School Five It turns out to be very important to read in this character as I have a program that loops through a data set and Sweave's about 30,000 files. The variable sch_name gets dropped into the tex file using \Sexpr{tmp$sch_name}. However, if there is an , the latex file won't compile properly. So, what I need is for the data to be read in as schid sch_name 1 331-802-7081School One 2 464-551-7357School Two 3 388-517-7627 School Three \ Four 4 388-517-4394 School Five I am obligated by a client to include the in the school name, so eliminating that isn't an option. I thought maybe comment.char or quote would be what I needed, but they didn't resolve the issue. I'm certain I'm missing something simple, I just can't see it. Any thoughts? Harold [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Plots Without Displaying
Yes, see ?jpeg ?bitmap and as you didn't tell us your OS we don't know if these are available to you. jpeg(file=test.jpg) boxplot(sample(100)) dev.off() may well work. 'An Introduction to R' explains about graphics devices, including these. On Wed, 16 Aug 2006, Lothar Botelho-Machado wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 R Help Mailing List, I'd like to generate a plot that I could display and/or store it as e.g. jpeg. But unfortunately always a plotting window opens. Is it possible to prevent that? I tried the following: R bp-boxplot( sample(100), plot=FALSE) This works somehow, but it only stores data (as discribed in the help) in bp and it is not possible afaik to display bp later on or store them as a jpeg. The next: R p-plot(sample(100), sample(100), plot=FALSE) ..and also a variant using jpeg() didn't work at all. Is there a way to generally store the plots as object, without displaying them, or perhaps directly saving them to disc as jpeg? A Yes or No or any further help/links are appreciated!!! -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Plots Without Displaying
On Thu, 17 Aug 2006, Lothar Botelho-Machado wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Thank you, It seems that a list of plots is just possible using lattice plots. But that's a good keyword for me to look for, I appreciate your help! Actually, that is not a list of *plots*. The objects stored there are more sets of instructions to the print method of what to plot, and you can do that for any type of plot. It is possible to store low-level descriptions of plots and replay them: see recordPlot and replayPlot. BUT, it is preferable to run the expressions to create the plot on the new device. Christos Hatzis wrote: Yes, you can do that for lattice-based plots. The functions in the lattice package produce objects of class trellis which can be stored in a list and processed or updated at a later time: library(lattice) attach(barley) plotList - list(length=3) plotList[[1]] - xyplot(yield ~ site, data=barley) plotList[[2]] - xyplot(yield ~ variety, data=barley) plotList[[3]] - xyplot(yield ~ year, data=barley) plotList plotList[[3]] - update(plotList[[3]], yaxis=Yield (bushels/acre)) print(plotList[[3]]) Obviously, you can store any lattice-based plot in the list. HTH. -Christos Christos Hatzis, Ph.D. Nuvera Biosciences, Inc. 400 West Cummings Park Suite 5350 Woburn, MA 01801 Tel: 781-938-3830 www.nuverabio.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Lothar Botelho-Machado Sent: Wednesday, August 16, 2006 4:49 PM To: r-help@stat.math.ethz.ch Subject: Re: [R] Plots Without Displaying Prof Brian Ripley wrote: Yes, see ?jpeg ?bitmap and as you didn't tell us your OS we don't know if these are available to you. jpeg(file=test.jpg) boxplot(sample(100)) dev.off() may well work. 'An Introduction to R' explains about graphics devices, including these. On Wed, 16 Aug 2006, Lothar Botelho-Machado wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 R Help Mailing List, I'd like to generate a plot that I could display and/or store it as e.g. jpeg. But unfortunately always a plotting window opens. Is it possible to prevent that? I tried the following: R bp-boxplot( sample(100), plot=FALSE) This works somehow, but it only stores data (as discribed in the help) in bp and it is not possible afaik to display bp later on or store them as a jpeg. The next: R p-plot(sample(100), sample(100), plot=FALSE) ..and also a variant using jpeg() didn't work at all. Is there a way to generally store the plots as object, without displaying them, or perhaps directly saving them to disc as jpeg? A Yes or No or any further help/links are appreciated!!! Thank you for the explanation and your patience in answering me this obviously very simple question!! Originally I tried to store plots directly in a list. So writing them directly to disc was just a good alternative. I knew that that jpeg() provides functionality for that, but didn't use it correctly. Hence, is it also possible to store a plot in a list, somehow? Kind regards, Lothar __ 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 commented, minimal, self-contained, reproducible code. -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE5HU1HRf7N9c+X7sRAguEAJ4855nuonJaB9VXHkGOr/SZhqow8wCfXcuB o8oqpYoJ7MXgnVtnuGAE5Yk= =ZWgN -END PGP SIGNATURE- __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] Maximum length of R GUI input line?
On Fri, 18 Aug 2006, Philippe Grosjean wrote: You should put your SQL query in a variable, and use this variable in your call. Something like: MyQuery - bla bla bla MyQuery - paste(MyQuery, more bla bla) # doMyRequest(MyQuery) Indeed. For the record, R has an limit of 1024 chars on input lines (from way back) and it cannot be altered. Best, Philippe Grosjean Eric Fegraus wrote: Hello, I'm using R 2.3.1 on Windows. I'm generating some very long SQL statements. I do this by using paste() which will contain many strings and variables. I'm getting an error when the the total line length is longer than about 1013 characters. For example, it works with the line containing 1013 characters and not when it is 1059. I've looked into adjusting the options(width) and a handful of other settings. I have a feeling there is some other setting i'm missing that i can adjust. Any ideas? Thanks! __ 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 commented, minimal, self-contained, reproducible code. __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] as.data.frame(cbind()) transforming numeric to factor?
On Fri, 18 Aug 2006, Tom Boonen wrote: Dear List, why does as.data.frame(cbind()) transform numeric variables to factors, once one of the other variablesused is a character vector? # x.1 - rnorm(10) x.2 - c(rep(Test,10)) Foo - as.data.frame(cbind(x.1)) is.factor(Foo$x.1) Foo - as.data.frame(cbind(x.1,x.2)) is.factor(Foo$x.1) # I assume there is a good reason for this, can somebody explain? Thanks. Only if you can explain the good reason why you did not just use data.frame(x.1, x.2)! cbind() makes a matrix out of vectors, here a character matrix. And then as.data.frame() converts character columns to factors. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] R-update - what about packages and ESS?
Without knowing your OS this is hard to answer (and is the wrong list for the ESS question). For Windows users, the packages part is covered in the rw-FAQ. For Unix-alikes, it all depends how the update was done, but normal package update mechanisms (such as RPM) will not wipe out previously installed R packages: nor will 'make install'. In either case you don't need root access to install packages, as you can use a private library. We have things set up so a user's R_LIBS is something like R_LIBS=~/Rlibrary:/usr/local/Rlibs:/usr/local/BioC and then install.packages() automatically installs into the user's own library (if it has been created). On Fri, 18 Aug 2006, Christian Hennig wrote: Hi there, it seems that if I update R, it doesn't find previously installed packages anymore and is also not found by ESS. Actually the update has been done by our system administrator who assumed that there would be no problems with these things (I don't have root access to this system) and will perhaps not be too keen on installing everything else again. Is there any simple way how ESS and the packages can be connected to the new R? I remember that whenever I updated R on my private computers, I installed everything else again as well - but that's certainly not everybodies taste... Best, Christian *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] string-to-number
On Sat, 19 Aug 2006, Marc Schwartz wrote: On Sat, 2006-08-19 at 07:58 -0400, Charles Annis, P.E. wrote: Greetings, Amigos: I have been trying without success to convert a character string, repeated.measures.columns [1] 3,6,10 into c(3,6,10) for subsequent use. as.numeric(repeated.measures.columns) doesn't work (likely because of the commas) [1] NA Warning message: NAs introduced by coercion I've tried many things including strsplit(repeated.measures.columns, split = ,) which produces a list with only one element, viz: [[1]] [1] 3 6 10 as.numeric() doesn't like that either. Clearly: 1) I cannot be the first person to attempt this, and 2) I've made this WAY harder than it is. Would some kind soul please instruct me (and perhaps subsequent searchers) how to convert the elements of a string into numbers? Thank you. One more step: as.numeric(unlist(strsplit(repeated.measures.columns, ,))) [1] 3 6 10 Use unlist() to take the output of strsplit() and convert it to a vector, before coercing to numeric. Or, more simply, use [[1]] as in as.numeric(strsplit(repeated.measures.columns, ,)[[1]]) Also, eval(parse(text=paste(c(, repeated.measures.columns, looks competitive, and is quite a bit more general (e.g. allows spaces, works with complex numbers), or you can use scan() from an anonymous file or a textConnection. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] problem with Rcmd check and fortran95, makefile
First, this is off-topic for R-help (see the posting guide, including the non-use of HTML, please). Second, the appropriate list needs to see exactly what the output was when you did this. Remember R CMD SHLIB is a *make* facility, and quite possibly the objects were not remade after changes. And yes, R CMD INSTALL does more than your commands -- as you have the sources you can take a look, or even see what the output says. Here is a simple F95 example (using gcc pre-4.2.0) -- Making package testf95 adding build stamp to DESCRIPTION making DLL ... c:/MinGW/bin/gfortran -O3 -c cos90.f95 -o cos90.o windres --include-dir d:/R/svn/trunk/include -i testf95_res.rc -o testf95_res.o c:/MinGW/bin/gfortran -shared -s -o testf95.dll testf95.def cos90.o testf95_res.o -Ld:/R/svn/trunk/bin -lR Note the extras, including a .def file. If you use R 2.3.1 patched or R-devel you just don't need a Makefile and you can use standard Fortran 9X. On Sat, 19 Aug 2006, data-ploner Meinhard Ploner wrote: Hi all, I have Win XP and R 2.3.1 on my notebook. I would like to write a package which includes some Fortran 95 code. Interestingly, if I compile and link the simple file test90.f90 directly with g95 -c test90.f90 g95 -shared -o test90.dll test90.o then PE Viewer ( a dll viewer) shows me the right functions in the export table, hence I can use the dll in R. But as it should become part of a package I wrote the simple src/Makefile F95=g95 prog: test90.f90 $(F95) -shared -o test90.dll test90.o test90.f90: test90.f90 $(F95) -c test90.f90 which looks totally equal to the 2 commands above. If I run now Rcmd check --no-latex test90 Rcmd install test90 then test90.dll is made but the export table is empty and therefore in R the functions cannot be loaded. Any idea? Can it be that Rcmd gives further flags to the compiler/linker? Any hints appreciated Meinhard Ploner South Tyrol (Italy) PS The fortran file is simply: SUBROUTINE BLABLA(A) !DEC$ ATTRIBUTES DLLEXPORT :: blabla### without this line the prob is the same :-( IMPLICIT DOUBLE PRECISION (A-H,O-Z) A=A+1 RETURN END SUBROUTINE BLABLA You could use --export-all-symbols [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] need to find (and distinguish types of) carriage returns in a file that is scanned using scan
On Sat, 19 Aug 2006, Quicke, Donald L J wrote: Hope this is not too trivial I am reading a large file using scan. Why scan? In one part of this file there is a chunk of text within which i need to know the positions of line breaks. But scan seems only only what? An example of the file is: a 0 1 0 bftt 020 cftt T 1 R a 0 1 2 1 2 b 0 1 2 2 2 c 0 10 00 so precisely i need in the scanned file in R to know where each carriage return is in the file so that i can then identify the text strings (i.e. a, bftt, cftt, a, b, c ) that immediately follow the carriage return Sounds like a job for readLines. On a subsidiary matter, it would be very helpful if i could distinguish between Unix, Dos, and Mac carriage returns in the data file AFAIK there is only type of carriage return character (ASCII code Ctrl-M). If you mean between CRLF, LF and perhaps CR line endings, you need to read the files as raw bytes since R's text mode regards all three as equally a line ending. But that can perfectly well be done using binary-mode connections. thanks i should note also, that the input file contains much other stuff and is not in the form of a table that can be read using read.table or other read version. Nor do i know beforehand how many elements there are in each line Sounds like a job for connections ... [[alternative HTML version deleted]] __ 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 commented, minimal, self-contained, reproducible code. PLEASE do as we ask. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] question about cbind()
On Sat, 19 Aug 2006, [EMAIL PROTECTED] wrote: Dear all, I have a question about how to get a matrix by combining a large number of columns from a data file. Suppose I read a file which have 1000 columns by: test = read.table(dat.txt, header=F) I know I could use cbind(). It's easy to do when the number of columns is small (i.e. cbind(test$V1, test$V2)). But how about build a matrix X by combine the first 500 columns. Is there an easy way to write the expression? as.matrix(test[1:500]) Or read the data as a matrix in the first place, using scan (as recommended on the help page for read.table *and* the relevant manual). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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 commented, minimal, self-contained, reproducible code.
Re: [R] issues with Sweave and inclusion of graphics in a document
savePlot is just an internal version of dev.copy, part of the support for the menus on the windows() graphics device. It is described in `An Introduction to R' (the most basic R manual). On Sat, 19 Aug 2006, Thomas Harte wrote: the problem is a little hard to explain; the .Rnw files (below) probably do a better job, but here goes ... Sweave doesn't like it when i size a graphical device in a code chunk using either, e.g.: windows(width=20, height=5) in Windows, or, e.g. x11(width=20, height=5) under X, when i then plot something in said device and try to include this graphical output in the resulting document. Sweave does not object to my writing code chunks in the above manner, so long as i do not wish to include the code in a LaTeX figure environment. oftentimes i want to do precisely what Sweave doesn't appear to allow. for example, with time-series data, i want to see a wide window on the screen as i code, and then i want to include the graphical output in my document the way that i fine tuned it on the screen. i don't want to write two pieces of code: the first, to view output on the sceen; the second, to save the output to a .pdf file for inclusion in the document. some example .Rnw files should illustrate my plight. suggestions on a workaround (i.e. how to do what i describe in linux/X) welcome. % example-windows.Rnw \documentclass[a4paper]{article} \begin{document} \noindent This is an example of what I can do on Windows. Unhappily, I seem to be able to squeeze marginally more out of \texttt{Sweave} \emph{chez\/} Bill Gates than I can under Linux. Ho, hum. echo=false,results=hide= # create a simple AR process: make.ar.1- function(alpha=1,n=300) { Z- rnorm(n); Y- numeric(n); Y[1]- Z[1]; for (i in 2:n) Y[i]- alpha*Y[i-1]+Z[i]; return(Y) } @ label=ar.1= # a long AR process is best viewed in a wide window: windows(width=20, height=5) sp- make.ar.1(alpha=.5, n=800) plot(sp, type=l, col=blue) # WISIWIS: What I See Is What I Save ;) savePlot(ar,type=pdf) @ \begin{figure} \begin{center} % imporantly, by saving the plot i have direct control over graphics in LaTeX, % and i can fine-tune the the graphics placement as much as i want: \includegraphics[width=14.5cm]{./ar.pdf} \caption{An AR(1) process of length~\protect\Sexpr{length(sp)} is best viewed in a wide window.} \end{center} \end{figure} \noindent Had I tried to do the following, \texttt{Sweave} would have blown up! \begin{verbatim} label=ar.1= windows(width=20, height=5) # - this is the offending command: sp- make.ar.1(alpha=.5, n=800) plot(sp, type=l, col=blue) @ \begin{figure} \begin{center} fig=true= ar.1 @ \caption{An AR(1) process of length~\protect\Sexpr{length(sp)} is best viewed in a wide window.} \end{center} \end{figure} \end{verbatim} \noindent The take-home message is that \texttt{savePlot} saves the day under Windows. As far as I know, there is no equivalent under Linux, or rather, under X. In Windows, then, \begin{itemize} \item I can plot the way I want on the screen; \item I can save that plot to a file without writing any other code; \item I can include the saved plot in my \LaTeX\ figure, allowing me to fine-tune with the [EMAIL PROTECTED]@ command. \end{itemize} Strike one for the Evil Empire. \end{document} % example-windows.Rnw % example-linux.Rnw \documentclass[a4paper]{article} \begin{document} \noindent This is an example of the hapless state of my \texttt{Sweave}ing under Linux. echo=false,results=hide= # create a simple AR process: make.ar.1- function(alpha=1,n=300) { Z- rnorm(n); Y- numeric(n); Y[1]- Z[1]; for (i in 2:n) Y[i]- alpha*Y[i-1]+Z[i]; return(Y) } @ \noindent Because of the [EMAIL PROTECTED](width=20, height=5)@ command, I can't embed the graphical output that the following piece of code produces in my document, although I can view the results on screen: label=first.ar.1= # a long AR process is best viewed in a wide window: x11(width=20, height=5) sp- make.ar.1(alpha=.5, n=800) plot(sp, type=l, col=blue) # no savePlot ... can't seem to do anything with this plot # if i try to include this code in a figure environment then # Sweave blows up # so i have to stop here :( @ \noindent Instead, I have to do something like the following, which has the unfortunate side effects of disallowing me from seeing the graphical output on the screen, and, probably more importantly, of duplicating the above code: