Re: [R] Creating GUIs for R
Greg Snow wrote: Wade, What type of GUI do you want? Do you want a full GUI that the user runs to do everything (that uses R as the computational engine)? Look at R commander, JGR, and the R plugin for Excel as possible examples. Hi Wade, I am trying to introduce some users to R without much success. Probably because my own R skills are really poor! Perhaps this R plugin for Excel could help. Please, could you point me to a website where I could look for it? Thanks! Ricardo -- Ricardo Rodríguez Your XEN ICT Team __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme and lmer df's and F-statistics again
Bert Gunter gunter.berton at gene.com writes: I think we owe Doug Bates a little more respect than that! If you check my postings on the forum and on my homepage (subject: Gastric Emptying), you will find that there are few people that pay so much respect to Douglas Bates' contributions than I do. I noted though that there was an ambiguous sentences in my previous note: Not to use lmer for gaussian models should have been extended by but to use lme instead when possible. Nevertheless, there is a problem that we as end users are left in a dangling state. Douglas Bates has made his point in a detailed statement on this list. After 20 years in applied medical statistics I am probable at 202 level, but I simply have to accept his arguments even if I do not understand all details. However, when I like the original poster have to rebut a referee's argument, it is very difficult to use a well-formulated list message to make a point in the three-capitals dominated world. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Vertex enumeration and center of mass for convex polytops
Hi Mosche, In my problem the polytope is defined not by its vertices, but by a set of linear equations and inequalities. Serguei Moshe Olshansky schrieb: Hi, If you know that all your points represent vertices of a convex polygon you do not need any special package. The center of mass is just the mean of the coordinates. To enumerate the vertices, compute the vectors from the center of mass to all the vertices. Using atan2 function compute the arguments of all these vectors (between 0 and 2*pi) and number the points according to their argument. --- On Wed, 1/10/08, Serguei Kaniovski [EMAIL PROTECTED] wrote: From: Serguei Kaniovski [EMAIL PROTECTED] Subject: [R] Vertex enumeration and center of mass for convex polytops To: [EMAIL PROTECTED] Received: Wednesday, 1 October, 2008, 10:00 PM Dear All! I am looking for a package that contains routines for vertex enumeration and center of mass computation for convex polytops. Thanks in advance, Serguei Kaniovski __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question from Braun/Murdoch book
On Wed, 8 Oct 2008, Erin Hodgess wrote: Hi R People: I am looking at the Braun/Murdoch book, A First Course in Statistical Programming in R, and I have a question about a function there. It's on page 52, Example 4.5; the sieve of Erastosthenes. There is a line: primes - c() Is there a difference between using that and primes - NULL please? When you put in primes - c(), primes comes back as NULL. Is one more efficient or is this just a matter of programming style, please? What would be more efficient is primes - integer(0) (as it looks like 'primes' concatenates integer vectors, at a quick glance). Use a function call c() to get NULL is not efficient, but all the differences here are tiny. Thanks in advance, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
Dear Michael, take a look at plotmeans in gplots library. library(gplots) example(plotmeans) Hope this helps, Gianandrea Michael Just wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. I've looked at lattice and gplots2, but given my beginner status my efforts are not propelling me very far. Thank you kindly, Michael Just [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Plot-means-with-error-bars---A-novice-needs-help-tp19872142p19873501.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help to debug C codes called from R
This might be Linux specific, I have never tried it on anything else: R -d gdb library(your-package) CTRL+C break an-entry-point-in-your-package-to-debug c your-function-to-debug() Maybe see also the R extensions manual, Gabor On Wed, Oct 8, 2008 at 3:28 AM, Droit Arnaud [EMAIL PROTECTED] wrote: Hello everybody, I have a package with a C codes called from R. I want to debug the C functions to check variables values and to include some breakpoints in the C codes. I am wondering if anyone knows of any tools to easily help debug in the R environment. Thank you very much for your help. Arnaud. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gabor Csardi [EMAIL PROTECTED] UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question from Braun/Murdoch book
Prof Brian Ripley wrote: On Wed, 8 Oct 2008, Erin Hodgess wrote: Hi R People: I am looking at the Braun/Murdoch book, A First Course in Statistical Programming in R, and I have a question about a function there. It's on page 52, Example 4.5; the sieve of Erastosthenes. There is a line: primes - c() Is there a difference between using that and primes - NULL please? When you put in primes - c(), primes comes back as NULL. Is one more efficient or is this just a matter of programming style, please? What would be more efficient is primes - integer(0) (as it looks like 'primes' concatenates integer vectors, at a quick glance). Use a function call c() to get NULL is not efficient, but all the differences here are tiny. btw., is(NULL) says that NULL is of the class NULL and OptionalFunction -- what is an OptionalFunction? ?Opttab completes to ?OptionalFunction-class, but the man page does not even mention OptionalFunction. apropos(OptionalFunction) points to .__C__OptionalFunction, but help.search(.__C__OptionalFunction) gives no results. if this is a low-level implementational detail, why should is(NULL) expose it? vQ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] print results from R
I want to print the following multiple boxes of output from R. - 1st stage |2nd stage | 3rd stage | x1|x2 | x3| | || - 5th stage |6th stage | 7th stage | x4|x5 | x6| | || - 1st stage |2nd stage | 3rd stage | x1|x2 | x3| | || Instead of manually typing all these numbers, can I have an easy way to output these in the right format from R? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R and Multi threading
On Wed, 8 Oct 2008, [EMAIL PROTECTED] wrote: Dear prof, and list! I'm wondering which are the steps to exploit multiple processors/cores if most of the processing time is due to C code dynamically loaded into R. I mean; e.g., a Monte Carlo analysis calls the C part a huge number of times, and it is this C part which takes most of the time. But you may well be able to do those parts in parallel. It depends on how the MCMC algorithm is organized. Will snow be anyway useful for this, or multithreading must be made explicit (I don't know how) within the C code, or there is nothing we can do? Please do your own homeork on what snow (etc) do, and how multithreaded BLAS work (and the ones I am familiar with are C code and use pthreads -- OpenMP is another possibility). Parallelization is (in general) hard and demands detailed understanding of the algorithms used (and of alternative algorithms). For example, the early 1990s debate on single vs multiple runs for MCMC was all about a single CPU, and the conclusions will be different if many CPUs are available at no extra cost. Javier G.P On Tue, 7 Oct 2008, pejpm wrote: I will preface this message by saying that I am not an R developer and no very little about R...but here is my situation: One of my users has developed a model for analysing commodity prices. At the moment when he runs this model on his daily data set it takes roughly 5 hours to complete. He is using a quad core PC with 2gb of RAM. The R process only uses 1 core..i.e. the overall CPU usage tops out at around 25%. This has been a managable situation for a while, but he would now like to run this model on 5 years of historical data. He has a colleague who ran the model on a 16 core Redhat Linux box, but it took even longer to run. He has asked me for assistance in speeding up this process. I have a couple of questions: 1) Is is possible to run the Windows version of R across all four processors? No. 2) I was under the impression that R for Linux supported multi-threading by default. Am I correct in this assumption? If not, is it possible for Linux R to multi thread, and how do I go about configuring this? Your impression/assumption is wrong. Apologies for the lack of detailed info in this post. I work in trade floor support and engineering and we dont really have much demand for this kind of heavy duty computational work so I am learning as I investigate this issue. R runs as a single task. It is possible that some of the the support functions (notably the BLAS) can be multithreaded, and this will often (but not always) help if the task is intensive numerical linear algebra. But even if a multithreaded BLAS is used (and it is not the default build), the effect on a typical R task is very small. If you want to exploit multiple processors/cores you need to split up your R job amongst multiple processes. There are ways to help you do that (packages snow and Rmpi, amongst others), but they need recoding of the job to make use of them. -- 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 -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Ecological Niche Modelling on R
It's very kind of Stephen to plug my book, but it's notwhat you're looking for. You need to read more about this general topic, and aboutthe particular packages: try http://www.unine.ch/CSCF/grasp/grasp-r/index.htmlhttp://www.unine.ch/CSCF/grasp/ Based on downloading grasp , it doesn't look as thoughit will handle presence-only data, though -- you may needto look further. It doesn't look like adehabitat is what you want.From Calenge, Clement. 2006. The package adehabitat for the R software: A toolfor the analysis of space and habitat use by animals. Ecological Modelling 197,no. 3-4 (August 25): 516-519. doi:10.1016/j.ecolmodel.2006.03.017. ' ... the “adehabitat” package for the R software, which offers basic GIS(Geographic Information System) functions, methods to analyze radio-trackingdata and habitat selection by wildlife, and interfaces with other R packages.' General advice about I want to do X in R -- (expandingon Stephen's advice above): 1. read about X in general (perhaps you have already done this);2. search for R packages and functions that do what you want (you've already done this, although you misidentified adehabitat3. install those packages and see what they do. Look at thedocumentation included with the packages, including any citationsreferenced. Try the examples.4. If you don't know enough R to understand the examples or howto get your data into R, back up and read the introductory Rdocumentation. Actually, the confusion could be explained by the fact that many analyses methods (and especially factor analyses) originally developed in community ecology and biogeography to study the niche are also used in habitat selection studies (e.g., OMI analysis, ENFA, etc.). As the statistical issues (predict the species/animal presence on an area, given the value of environmental variables) and type of data (presence-only data to be compared with a sample/census of available units, etc.) involved in studies of the niche and habitat selection are often similar, the methods used are often similar too... However, most of the functions in adehabitat implement /exploratory/ methods of the ecological niche, and methods suitable for prediction are rare in the package (except one or two functions which have already been used for that, such as mahasuhab or domain, but they are probably not the best choice given your aim)... The package grasp may indeed be a better choice if your aim is prediction... But I concur with Ben and Stephen on the fact that you should first read the (large) literature on niche modelling before choosing the method that seems appropriate to your data/issue, and then search R archives/package for a solution. a good start: @ARTICLE{Elith2006, author = {Elith, J. and Graham, C.H. and Anderson, R.P. and Dudik, M. and Ferrier, S. and Guisan, A. and Hijmans, R.J. and Huettmann, F. and Leathwick, J.R. and Lehmann, A. and Li, J. and Lohmann, L.G. and Loiselle, B.A. and Manion, G. and Moritz, C. and Nakamura, M. and Nakazawa, Y. and McC. Overton, J. and Peterson, A.T. and Phillips, S.J. and Richardson, K. and Scachetti-Pereira, R. and Schapire, R.E. and Soberon, J. and Williams, S. and Wisz, M.S. and Zimmermann, N.E.}, title = {Novel methods improve prediction of species distributions from occurrence data}, journal = {Ecography}, year = {2006}, volume = {29}, pages = {129-151} } and references therein. Cheers, Clément Calenge. -- Clément CALENGE Office national de la chasse et de la faune sauvage Saint Benoist - 78610 Auffargis tel. (33) 01.30.46.54.14 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
You haven't given any of the information asked for in the posting guide. But, assuming this is Windows in CP1252 (as I believe that has been your locale before), it works for me in current R. plot(1:10) file.label - foo savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) If you are not using 2.8.0 beta or 2.7.2 patched, please check those. This might be related to o file.path() did not work correctly in 2.7.0 if the components had different encodings. (NEWS for 2.7.1). On Sun, 5 Oct 2008, Charles Annis, P.E. wrote: Greetings R-wizards: For historical reasons I have filenames with the character â and have successfully used \u00e2 in its place, with the hoped-for result on all my on-screen plots. However since R2.7.0 I have trouble with savePlot() when the file name includes that character as it does in this example: savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) In R2.6.0 and earlier, R would ignore a dot ('.') in the file name and supply the extension. Since R2.7.0 if filename does include a dot, savePlot() will not add the file type as an extension. Thus my apparent redundancy in the file name. The problem I have is that the example command will substitute an unwanted character for â, yet if I use File, save as, jpg ... and type in a name containing the troublesome character, R saves the on-screen plot with that character in the name with no complaints. I have tried using iconv() with no success, as can be seen with the following code: file.name - paste(diagnostic â vs a , file.label, .jpg, sep = ) iconv.List - iconvlist() for(encoding in iconv.List) { print(iconv(file.name, , encoding, ))} So, here's the question: How can I save, with a non-interactive R command, an existing plot with the troublesome character in the file name? Thanks. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question from Braun/Murdoch book
I am looking at the Braun/Murdoch book, A First Course in Statistical Programming in R, and I have a question about a function there. It's on page 52, Example 4.5; the sieve of Erastosthenes. There is a line: primes - c() Is there a difference between using that and primes - NULL please? When you put in primes - c(), primes comes back as NULL. They return the same thing identical(c(), NULL)#TRUE Is one more efficient or is this just a matter of programming style, please? system.time(for(i in 1:100) c()) # user system elapsed # 0.630.020.64 system.time(for(i in 1:100) NULL) # user system elapsed # 0.280.000.28 Using NULL appears to be quicker on my machine, but given that you can do a million of these assignments in a fraction of a second, it makes no practical difference. NULL is perhaps more intuitive than c() for demonstrating that the variable is empty. Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] issues with write.table
Dear R gurus and users, I'm having problems with the use of write.table. I have a 28-variables data frame create at each cycle of a loop; it can contain between 2000 and 3000 rows for each cycle. After each cycle the data frame is written out to a file with the append=TRUE option and then removed from memory. These are the couple of lines involved: data2 - format.data.frame(sorted_data) write.table(data2,file=R_toscala.txt,append=TRUE,quote=FALSE,sep=\t,row.names=FALSE,col.names=FALSE) rm(tmp,new_xyz,u0,u1,data,data0,data1,data2,data3,data4,templ0,templ1,f0,f1,frac,Xdet,Ydet,tthr,tth,tras_coef,sc,srs,sup,sdown,rs,lorentz,pola,rot,sorted_data) You can see that data2 is removed at each cycle together with other objects in order to free memory. Now everything is OK when the written file, R_toscala.txt grows roughly to 10 lines. But my code writes wrong values after that. I suspect there might be issues with files size or with stack size, but am absolutely not sure about it. I am running Ubuntu 8 - 64bit. The ulimit -a gives: core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 40960 max locked memory (kbytes, -l) 32 max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size(512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 40960 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited Any idea of what is going wrong here? Many thanks, James Dr James Foadi PhD Membrane Protein Laboratory (MPL) Diamond Light Source Ltd Diamond House Harewell Science and Innovation Campus Chilton, Didcot Oxfordshire OX11 0DE Email: [EMAIL PROTECTED] Alt Email: [EMAIL PROTECTED] DIVFONT size=1 color=grayThis e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail. Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message. Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom /FONT/DIV __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fw: MLE
On 08-Oct-08 11:14:39, Ron Michael wrote: I made one typo in my previous mail. May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Consistent as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance. Can anyone please clarify me? Your help will be highly appreciated. The false step in your argument is in the following: If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. The first part would better expressed as: If it is consistent then asymptotically it should collapse *towards* truth and indeed that is pretty well the definition of consistent. More precisely: 1. Decide how close you want the MLE to be to the true value. (Say, for example, that this is 0.0001). You're not allowed to choose spot on (i.e. zero). 2. Decide how sure you want to be that it is that close (Say, for example, that you want to be 99.999% sure). You're not allowed to choose 100%. 3. Then you can find a sample size N (which may be very large, but you are being asymptotic so you can take as much as you need) such that, if the sample size it as least N, then Probability(|MLE - Truth| 0.0001) 0.9 N, of course, depends on the numbers you chose in (1) and (2). Not that this does NOT say, anywhere, that the distribution of the MLE has, for such an N, collapsed strictly to truth, i.e. that the variance is zero. All that is implied is that the variance is very small, sufficiently small for (3) to be true. And that is all that consistency is saying: That, for large enough N, you can be as sure as you wish (via variance as small as you need) that the MLE is at least as close as you wish to the true value. Consistency is not saying more than that. Therefore the second part of your statement: i.e. for large sample size, variance of MLE should be zero. is not true: you don't attain zero for any large sample size; you can only get very close. (Except in certain very special cases -- e.g. sampling 100 different items out of a population of 100 items, i.e. without replacement, will give you exactly the value of some quantity calculated on that population). Hoping that helps! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 08-Oct-08 Time: 13:14:27 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating GUIs for R
This is more or less the same information I posted recently that may be of help here. On Tue, Oct 7, 2008 at 8:32 PM, Wade Wall [EMAIL PROTECTED] wrote: What I am wanting to do is learn to build some simple GUIs for a limited number of functions. Basically, I am envisioning a screen with check boxes, a drop down menu etc. that users could select to run analyses on imported data. One option is to create a plugin package for Rcmdr [1]. Rcmdr allows you to take full control of its menus, including removing the default ones, which means that you can take the existing infrastructure and adapt it to your specific needs. Rnews contains documentation on Rcmdr and on writing plugins for Rcmdr Regards, Liviu [1] http://cran.r-project.org/web/packages/Rcmdr/index.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitting weibull, exponential and lognormal distributions to left-truncated data.
On Wed, 8 Oct 2008, Gough Lauren wrote: Hi, Thank you very much for your reply. This seems to be working OK when fitting weibull and lognormal distributions. However, fitdistr now requires me to include start values: As documented. ltwei-function(x,shape,scale,log=FALSE){ + dweibull(x,shape,scale,log)/pweibull(1,shape,scale,lower=FALSE) + } ltweifit-fitdistr(x,ltwei) # x is observed data Error in fitdistr(x, ltwei) : 'start' must be a named list ltweifit-fitdistr(x,ltwei,start=list(shape=0.5,scale=0.5)) There were 34 warnings (use warnings() to see them) ltweifit shape scale 1.11108278 13.00703630 ( 0.01936651) ( 0.42897340) Is there anyway I can fit to truncated data without having to name start values? Alternatively, is there any recommended technique for choosing sensible start values? Not really, depends how heavy the truncation is. Further, when I try to fit an exponential distribution I get an error message: But a truncated exponential is just a shifted exponential and has one parameter -- you gave it two! Just fit an exponential to x-1. ltexp-function(x,rate,log=FALSE){ + dexp(x,rate,log)/pexp(1,rate,lower=FALSE) + } ltexpfit-fitdistr(x,ltexp) Error in fitdistr(x, ltexp) : 'start' must be a named list ltexpfit-fitdistr(x,ltexp,start=list(0.1)) Warning message: In optim(x = c(2.541609, 1.436143, 4.600524, 6.437174, 2.84974, : one-diml optimization by Nelder-Mead is unreliable: use optimize ltexpfit Error in dn[[2]] : subscript out of bounds This error message seems to occur regardless of the start value used. Do you know why this is? Sorry to pester you again, and apologies if I am asking silly questions - my knowledge of R and probability distributions (except the normal!) are rather limited! Best wishes Lauren -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 07 October 2008 12:25 To: [EMAIL PROTECTED] Cc: Gough Lauren; vito muggeo; r-help@r-project.org Subject: Re: [R] Fitting weibull, exponential and lognormal distributions to left-truncated data. On Tue, 7 Oct 2008, [EMAIL PROTECTED] wrote: I have several datasets, all left-truncated at x=1, that I am attempting to fit distributions to (lognormal, weibull and exponential). I had been using fitdistr in the MASS package as follows: A possible solution is to use the survreg() in the survival package without specifying the covariates, i.e. library(survival) survreg(Surv(..)~1, dist=weibull) where Surv(..) accepts information about times, censoring/truncation variables and dist allows to specify alternative distributions. See ?Surv e ?survreg The survival package is mostly targeted at right-censored data. The NADA package provides wrappers for many of the survival routines so they work with left-censored data. Left-censoring and left-truncation are not the same thing. With left-censoring you see that you had observations 1, and with left-truncation you do not (at least how the terms are usually applied: occasionally the meanings are reversed). For left-truncation it is relatively easy, e.g. ltwei - function(x, shape, scale = 1, log = FALSE) dweibull(x, shape, scale, log)/pweibull(1, shape, scale, lower=FALSE) and use this in fitdistr. -- 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 This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question from Braun/Murdoch book
On 08/10/2008 1:48 AM, Erin Hodgess wrote: Hi R People: I am looking at the Braun/Murdoch book, A First Course in Statistical Programming in R, and I have a question about a function there. It's on page 52, Example 4.5; the sieve of Erastosthenes. There is a line: primes - c() Is there a difference between using that and primes - NULL please? When you put in primes - c(), primes comes back as NULL. Is one more efficient or is this just a matter of programming style, please? It was purely a choice of style. By the way, there is an error in one of the programs coming soon after that: the mergesort example that starts on p. 68 doesn't handle odd-length input properly, because it uses len / 2 in a number of places where it really needs len %/% 2. So for example, when len is 3 we get behaviour like this: x - 1:3 len - 3 x[1:(len/2)] [1] 1 x[(len/2 + 1):len] [1] 2 (and the 3 got lost). Using the integer divide is fine: x[1:(len %/% 2)] [1] 1 x[(len %/% 2 + 1):len] [1] 2 3 Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help to debug C codes called from R
On 07/10/2008 9:28 PM, Droit Arnaud wrote: Hello everybody, I have a package with a C codes called from R. I want to debug the C functions to check variables values and to include some breakpoints in the C codes. I am wondering if anyone knows of any tools to easily help debug in the R environment. You can use whatever debugger you normally use for C code, e.g. gdb/insight/ddb if you are using the usual gcc tools to build it. For details on doing this in Windows, see www.stats.uwo.ca/faculty/murdoch/software/debuggingR Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Programing and writing function help
Stephen Cole wrote: ... I have a vector of 20 values x - c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30) 1. I want to select random pairs from this data set but do it without replacement exhaustively matrix(x[sample(1:20,20)],nrow=2) then step through the columns of the resulting matrix I know i can select random pairs without replacement using sample(N,n,replace=F) However i am wondering if there is any way to get 10 random pairs from this data set without repeating any of the data points that is to say if i got a (20, 94) for one pair, i would like to get 9 other pairs from the data without again getting 20 or 94? 2. The second thing i would like to do is be able to select all possible pairs of numbers and calculate each pairs variance. I think you want to use the combn function, but you are going to get a lot of pairs... Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
Thank you, Professor Ripley: Your example works for me too. plot(1:10, xlab = a, ylab = â) file.label - EXAMPLE 1 â vs a.xls savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) But, if I read-in the file name using file.choose() I get the same corrupted output filename ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ) from my R routines. However, if I paste that same file.label as it is printed to the screen with my input routine, replacing your foo (as above) things work as they should ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ). Furthermore, if I again run my plotting routines after your example (like that here, above), my routines no longer produce corrupted filenames for the saved plots. The trouble seems to be caused by my how I read-in the file name. Here is a simple example that produces a corrupted file name for the saved plot: plot(1:10, xlab = a, ylab = â) file.name - file.choose() print(file.name) file.label - basename(file.name) savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) The name of my input Excel file is EXAMPLE 1 â vs a.xls The problem does not occur on R R2.7.0 I am running R2.7.2 on a 5 year old DELL box (2 Gig RAM, 3GHz Pentium 4) with Windows XP, and have also experienced the problem on my Thinkpad laptop (2 Gig, Intel Core2 Duo, 1.6GHz) running Vista. Thank you for your counsel. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 4:39 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: Re: [R] trouble with character \u00e2 You haven't given any of the information asked for in the posting guide. But, assuming this is Windows in CP1252 (as I believe that has been your locale before), it works for me in current R. plot(1:10) file.label - foo savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) If you are not using 2.8.0 beta or 2.7.2 patched, please check those. This might be related to o file.path() did not work correctly in 2.7.0 if the components had different encodings. (NEWS for 2.7.1). On Sun, 5 Oct 2008, Charles Annis, P.E. wrote: Greetings R-wizards: For historical reasons I have filenames with the character â and have successfully used \u00e2 in its place, with the hoped-for result on all my on-screen plots. However since R2.7.0 I have trouble with savePlot() when the file name includes that character as it does in this example: savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) In R2.6.0 and earlier, R would ignore a dot ('.') in the file name and supply the extension. Since R2.7.0 if filename does include a dot, savePlot() will not add the file type as an extension. Thus my apparent redundancy in the file name. The problem I have is that the example command will substitute an unwanted character for â, yet if I use File, save as, jpg ... and type in a name containing the troublesome character, R saves the on-screen plot with that character in the name with no complaints. I have tried using iconv() with no success, as can be seen with the following code: file.name - paste(diagnostic â vs a , file.label, .jpg, sep = ) iconv.List - iconvlist() for(encoding in iconv.List) { print(iconv(file.name, , encoding, ))} So, here's the question: How can I save, with a non-interactive R command, an existing plot with the troublesome character in the file name? Thanks. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Programing and writing function help
Actually, you will have duplicates with 400 pairs. Here you will have 13^2 pairs with replacement and 13*12 pairs without replacement and with regard to order. How about this: z - unique(x) y - expand.grid(z[1:13],z[1:13]) xx - y[,1] != y[,2] y[xx,] Just another thought. Erin On Wed, Oct 8, 2008 at 5:55 AM, Erin Hodgess [EMAIL PROTECTED] wrote: For all possible pairs, you'll have 20^2 pairs. This is a way to do it: expand.grid(x[1:20],x[1:20]) HTH, Erin On Wed, Oct 8, 2008 at 4:43 AM, Jim Lemon [EMAIL PROTECTED] wrote: Stephen Cole wrote: ... I have a vector of 20 values x - c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30) 1. I want to select random pairs from this data set but do it without replacement exhaustively matrix(x[sample(1:20,20)],nrow=2) then step through the columns of the resulting matrix I know i can select random pairs without replacement using sample(N,n,replace=F) However i am wondering if there is any way to get 10 random pairs from this data set without repeating any of the data points that is to say if i got a (20, 94) for one pair, i would like to get 9 other pairs from the data without again getting 20 or 94? 2. The second thing i would like to do is be able to select all possible pairs of numbers and calculate each pairs variance. I think you want to use the combn function, but you are going to get a lot of pairs... Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
Michael Just wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. I've looked at lattice and gplots2, but given my beginner status my efforts are not propelling me very far. Hi Michael, Have a look at the barp function in the plotrix package. You can add error bars using the dispersion or dispbars function. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Ecological Niche Modelling on R
Dear All, Thanks for all very interesting replies. In fact I have read all the recent publications on ENM (Ecological Niche Modeling), and many of them use GARP (Genetic Algorithm for Rule Prediction; sensu STockwell Peterson 2001) and Maxent (Maximum Entropy sensu Philips Dudik, 2008a, b) algorithms. I can run my modeling on DescktopGarp, Maxent, and also on OpenModeller (which have implementation of a large set of algoritms). I agree with Dr. Calenge that Elith et al (2006) is an interesting reading. But, unfortunatelly up to now none of papers regarding ENM use R as a modelling tools. And my intent on last email was to start a comparative modelling using both R and non-R solution. Whem I require adehabitat package I get the following message: Type: demo(rastermaps) for demonstration of raster map analysis demo(homerange) for demonstration of home-range estimation demo(managltraj) for demonstration of animals trajectory management demo(analysisltraj) for demonstration of animals trajectory analysis demo(nichehs) for demonstration of niche/habitat selection analysis So, I was thinking if the last demo(nichehs) could be used on this task once visually this suggests that the package could help someone on both niche model/habitat selection analysis. So, Dr. BBolker, I think the adehabitat is not only for GIS(Geographic Information System) functions, methods to analyze radio-trackingdata and habitat selection, but mainly for it. By the way, Dr. BBolker, I read your book three rimes, and I each time that I read I get more facinated (Thanks and congratulations!). In fact, after read the book on digital format, I am waiting the hard-copy arrive on next week. By the way, after read Ecological Detectives and the BBolker book, I hardly suggest those interested on Ecological Modelling and Data Analysis start reading from the BB´s book. Mainly if one have R-capability as we almost on some levels have. Finally, in fact GRASP do what I am looking for, and I am starting to compare the results of this packages with other very wel- know softwares (DescktopGarp, Maxent, OpenModeller). If someone of you have suggestions of other R-solutions for Ecological Niche Models, please, let-me know. Dr. BB, I read all the available documentations on GRASP, but unfortunatelly the preparation of input data (a set of tables instead of conventional layers and XY coordinates) is not so clear thoughout the text. Good data modelling for all. Thanks for your time. Regards a lot. Savava. Miltinho Astronauta Brazil On Wed, Oct 8, 2008 at 6:02 AM, Clément Calenge [EMAIL PROTECTED] wrote: It's very kind of Stephen to plug my book, but it's notwhat you're looking for. You need to read more about this general topic, and aboutthe particular packages: try http://www.unine.ch/CSCF/grasp/grasp-r/index.htmlhttp://www.unine.ch/CSCF/grasp/ Based on downloading grasp , it doesn't look as thoughit will handle presence-only data, though -- you may needto look further. It doesn't look like adehabitat is what you want.From Calenge, Clement. 2006. The package adehabitat for the R software: A toolfor the analysis of space and habitat use by animals. Ecological Modelling 197,no. 3-4 (August 25): 516-519. doi:10.1016/j.ecolmodel.2006.03.017. ' ... the adehabitat package for the R software, which offers basic GIS(Geographic Information System) functions, methods to analyze radio-trackingdata and habitat selection by wildlife, and interfaces with other R packages.' General advice about I want to do X in R -- (expandingon Stephen's advice above): 1. read about X in general (perhaps you have already done this);2. search for R packages and functions that do what you want (you've already done this, although you misidentified adehabitat3. install those packages and see what they do. Look at thedocumentation included with the packages, including any citationsreferenced. Try the examples.4. If you don't know enough R to understand the examples or howto get your data into R, back up and read the introductory Rdocumentation. Actually, the confusion could be explained by the fact that many analyses methods (and especially factor analyses) originally developed in community ecology and biogeography to study the niche are also used in habitat selection studies (e.g., OMI analysis, ENFA, etc.). As the statistical issues (predict the species/animal presence on an area, given the value of environmental variables) and type of data (presence-only data to be compared with a sample/census of available units, etc.) involved in studies of the niche and habitat selection are often similar, the methods used are often similar too... However, most of the functions in adehabitat implement /exploratory/ methods of the ecological niche, and methods suitable for prediction are rare in the package (except one or two functions which have already been used for that, such as mahasuhab or domain, but they are probably not the best
[R] Suspicious output from lme4-mcmcsamp
Hello, R community, I have been using the lmer and mcmcsamp functions in R with some difficulty. I do not believe this is my code or data, however, because my attempts to use the sample code and 'sleepstudy' data provided with the lme4 packaged (and used on several R-Wiki pages) do not return the same results as those indicated in the help pages. For instance: sessionInfo() R version 2.7.2 (2008-08-25) i386-pc-mingw32 locale: LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lme4_0.999375-26 Matrix_0.999375-11 lattice_0.17-13 loaded via a namespace (and not attached): [1] grid_2.7.2 fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy) sm1 - mcmcsamp(fm1, 5000) Error in .local(object, n, verbose, ...) : Code for non-trivial theta_T not yet written ## I cannot find exactly what this theta_T error means, although I do find it mentioned in what I believe to be source code. Regardless, I cannot understand why the mcmcsamp returns the error for this data set. Even when I change the model and the mcmcsamp appears to run, the output is not as expected: fm2 - lmer(Reaction ~ Days + (1|Subject), sleepstudy) sm2 - mcmcsamp(fm2, 5000) summary(sm2) Length ClassMode 1 merMCMC S4 str(sm2) Formal class 'merMCMC' [package lme4] with 9 slots ..@ Gp : int [1:2] 0 18 ..@ ST : num [1, 1:5000] 1.198 0.932 0.835 0.826 0.933 ... ..@ call: language lmer(formula = Reaction ~ Days + (1 | Subject), data = sleepstudy) ..@ deviance: num [1:5000] 1794 1794 1796 1798 1798 ... ..@ dims: Named int [1:17] 1 180 2 18 1 1 1 2 5 1 ... .. ..- attr(*, names)= chr [1:17] nf n p q ... ..@ fixef : num [1:2, 1:5000] 251.4 10.5 253.3 11.0 259.5 ... .. ..- attr(*, dimnames)=List of 2 .. .. ..$ : chr [1:2] (Intercept) Days .. .. ..$ : NULL ..@ nc : int 1 ..@ ranef : num[1:18, 0 ] ..@ sigma : num [1, 1:5000] 31.0 29.7 30.4 28.4 38.1 ... ## As I understand it, the call summary(sm2) should return information of the results of the mcmcsamp distribution.In addition, I am expecting the str(sm2) to show the 'fixef' slot to have something resembling log(sigma^2) and log(Subject.(In)). Am I wrong? Are all of the outputs in the correct form? Has anyone else had this problem? Could this be related to the possible 'mistake in the mcmcsamp function at present' mentioned in the recent postings regarding the $ST and $sigma slots (Re: mcmcsamp(lme4): What is contained in $ST and $sigma?)? Any thoughts, suggestions, or directions would, of course, be most appreciated. Many thanks! Jenn Jennifer DeWoody University of Southampton School of Biological Sciences Building 62, Room 6007, Boldrewood Campus Southampton SO16 7PX United Kingdom Voice: +44 (0)23 8059 4286 Email: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] partial autocorrelation plots ACF type=p
Dear users, I have two continuous variables which are two different measures taken each year from 1975 to 2005. I want to see if the two variables are correlated but need to take into account the fact that they are a time series. I have been following an example from 'The R Book' where you plot the ACF: par(mfrow=c(1,1) acf(cbind(x,y)) and this appeared to work fine, producing four graphs for the autocorrelation of x,x y,y x,y and y,x. Then the next step in the example was to plot the partial autocorrelation: acf(cbind(x,y),type=p) When i do this however three of my graphs x,x y,y and y,x contain no data, the x,y graph contains data but has no lines of significance and all four of the graphs are on vertical scales of -2000 to 6000. I am new to time series analysis and from what i have read the partial autocorrelation plots should come out on a vertical scale of -1 to 1. I dont know why my partial autocorrelation plots are not working when the autocorrelation plots seemed to be no problem. If anyone has any suggestions I would be grateful. Thank you in advance. Claire -- View this message in context: http://www.nabble.com/partial-autocorrelation-plots-ACF-type%3Dp-tp19878665p19878665.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Programing and writing function help
For all possible pairs, you'll have 20^2 pairs. This is a way to do it: expand.grid(x[1:20],x[1:20]) HTH, Erin On Wed, Oct 8, 2008 at 4:43 AM, Jim Lemon [EMAIL PROTECTED] wrote: Stephen Cole wrote: ... I have a vector of 20 values x - c(20,18, 45, 16, 47, 47, 15, 26, 14,14,12,16,35,27,18,94,16,26,26,30) 1. I want to select random pairs from this data set but do it without replacement exhaustively matrix(x[sample(1:20,20)],nrow=2) then step through the columns of the resulting matrix I know i can select random pairs without replacement using sample(N,n,replace=F) However i am wondering if there is any way to get 10 random pairs from this data set without repeating any of the data points that is to say if i got a (20, 94) for one pair, i would like to get 9 other pairs from the data without again getting 20 or 94? 2. The second thing i would like to do is be able to select all possible pairs of numbers and calculate each pairs variance. I think you want to use the combn function, but you are going to get a lot of pairs... Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Factor tutorial?
Thank you very much. This will give me something to chew on for quite some time. Kevin [EMAIL PROTECTED] wrote: On 07-Oct-08 22:23:22, Bert Gunter wrote: But it **is** indexed in both of VR's MASS and S Programming. I have no idea whether the info there will be helpful to you, of course. I would find (and have found) it so. -- Bert Gunter The discussion of factors in VR is certainly quite comprehensive, but it is not for beginners! A more elementary and very readable published text is Peter Dalgaard's Introductory Statistics with R. An even more introductory, but still adequate, account can be found in various places of Julian Faraway's Practical Regression and Anova using R which is on-line on CRAN under Documentation/Contributed. However, you will need to piece together the bigger picture from passages found in various places. There is no index, but a search for factor in the PDF file throws up: pages 11; 69-70; Chapter 15 (160-167) -- especially section 15.2; Chapter 16 (168-203) -- though this deals mainly with factorial experimental designs. A reference with more detail at the technical level from the R viewpoint (but still well spelt out) is John Maindonald's Using R for Data Analysis and Graphics - Introduction, Examples and Commentary, especially section 2.4. This is also on-line in the same section of CRAN. That being said, on the grounds that an introductory outline may also be useful to others, here is a summary. Factors are variables which, essentially, introduce a contingency table structure into the data (and they can co-exist with variables which have quantitative interpretation). A factor is a variable with categorical values -- an item is an A, or a B, or a C, ... -- used in a particular way. It may or may not make sense to consider A, B, C, ... as ordered: A B C ... say. For example, a variable called Sex may have values M (for Male) or F (for Female). Whether one can consider that M F is something I will not discuss (though others may have a view). Or Social Class may have categories A (highest) B C D E (lowest). Or, say, an ecological classification of terrain may use Grassland, Forest, Swamp with no implication of any ordering: they are all on the same footing. The category labels of factors are called Levels. As seen in the data, these labels may be alphabetic, numeric, or both -- e.g. M or F for Sex, which people also often code as 1 or 2 (but with no implication that 1 2); Terrain may be G, F or S or 1, 2, 3; Social Class my be subdivided into A1, A2, B1, B2, ... (with implied ordering A1 A2 B1 B2 ... ). In regression analysis, the usefulness of factors is that they allow comparison between the outcomes for different levels of the factors. In simple cases the result may be as simple as the difference between the mean of cases with level A and the mean of cases with level B of sa single factor. This is where the plot starts to thicken. For example, if Terrain were coded 1, 2, 3 you would not want to treat these as quantitative values (even if they represented ordered levels). Instead, a factor with k levels is presented to the regression in terms of k dummy variables. If the regression model has an intercept, then one level (the base level) of the factor will be absorbed into the Intercept. So, for instance, data on weight(Kgm) might look like Sex Weight M69.5 F60.2 F65.7 M72.5 This would be transformed into Sex.M Sex.F Weight 1 0 69.5 0 1 60.2 0 1 65.7 1 0 72.5 where, now, the 0s and 1s will have their *quantitative* interpetation. So the regression model Weight ~ Sex now becomes the quantitative regression Weight = a + b.M*Sex.M + b.F*Sex.F + error using the values 0 and 1 of Sex.M and Sex.M quantitatively. However, since Sex.F + Sex.M = 1 throughout, one is redundant in the presence of the intercept (whose dummy equivalent has value 1 throughout). Hence the results of this regression will usually be presented as Intercept together with the coefficient of (say) Sex.F. However, if you left out the Intercept, giving the model formula Weight ~ Sex - 1, then the above data matrix with both dummy variables Sex.M and Sex.F would be used in full in the regression, whoch would fit the equation Weight = b.M$Sex.M + b.F*Sex.F + error without redundancy (and in this case the coeficients would be the mean of the weights of Males [b.M] and the mean of the weights of Females [b.F]). If there are two factors in the regression, say Sex (M/F) and Diet (M = meat-eater, V = vegetarian), then the possibilities are richer. One might then have, for the regression model Weight ~ Sex + Diet Sex.M Sex.F Diet.M Diet.V Weight 1 0 0 1 69.5 0 1 0 1 60.2 0 1 0 1 65.7 1 0
[R] Fw: MLE
I made one typo in my previous mail.  May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Consistent as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance.  Can anyone please clarify me? Your help will be highly appreciated. --- On Wed, 8/10/08, Ron Michael [EMAIL PROTECTED] wrote: From: Ron Michael [EMAIL PROTECTED] Subject: [R] MLE To: [EMAIL PROTECTED] Date: Wednesday, 8 October, 2008, 6:05 PM May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Efficient as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance.  Can anyone please clarify me? Your help will be highly appreciated.  Get your new Email address! Grab the Email name you#39;ve always wanted before someone else does! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[elided Yahoo spam]] il. [[elided Yahoo spam]] [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] MLE
May I ask one statistics related question please? I have one query on MLE itself. It's property says that, for large sample size it is normally distributed [i.e. asymptotically normal]. On the other hand it is Efficient as well. My doubt is, how this two asymptotic properties exist simultaneously? If it is consistent then asymptotically it should collapse to truth i.e. for large sample size, variance of MLE should be zero. However asymptotic normality says, MLE have some distribution and hence variance. Â Can anyone please clarify me? Your help will be highly appreciated. Â Get your new Email address! Grab the Email name you#39;ve always wanted before someone else does! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating GUIs for R
On Tue, Oct 7, 2008 at 10:32 AM, Wade Wall [EMAIL PROTECTED] wrote: Sorry that my post wasn't very clear. What I am wanting to do is learn to build some simple GUIs for a limited number of functions. Basically, I am envisioning a screen with check boxes, a drop down menu etc. that users could select to run analyses on imported data. My guess is you'll get the best usability if you design a GUI specific for your task, rather than constraining yourself to the model of 1-1 mapping between R functions and dialogs. In that case, I highly recommend using gWidgets as your first shot at a GUI in R. I have worked with VB before, but it has been several years and I am not sure how it interfaces with R. On Tue, Oct 7, 2008 at 1:20 PM, Bert Gunter [EMAIL PROTECTED] wrote: Seek and ye shall find ... Check the RGUI's link on the other web page on CRAN. If you are on Windows, there is some simple built-in GUI functionality. ?winMenuAdd, ?select.list and the links therein will get you started there. Cheers, Bert Gunter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wade Wall Sent: Tuesday, October 07, 2008 9:56 AM To: [EMAIL PROTECTED] Subject: [R] Creating GUIs for R Hi all, I have looked around for help on creating GUIs for R, but haven't found anything. I would be interested in any advice or webpages that have information on the best language, tutorials etc. for creating simple GUIs. Mainly I want to do this as a heuristic exercise. Thanks for any help. Wade Wall [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
That also works without a hitch on my box, even in vanilla 2.7.2. What exactly is in file.label as given by charToRaw(file.label) Encoding(file.label) ? It should be in UTF-8, and so should paste(diagnostic â vs a , file.label, .jpg, sep = ) It looks like the latter is not being treated as UTF-8 on your system (see what Encoding() says on its value). On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you, Professor Ripley: Your example works for me too. plot(1:10, xlab = a, ylab = â) file.label - EXAMPLE 1 â vs a.xls savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) But, if I read-in the file name using file.choose() I get the same corrupted output filename ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ) from my R routines. However, if I paste that same file.label as it is printed to the screen with my input routine, replacing your foo (as above) things work as they should ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ). Furthermore, if I again run my plotting routines after your example (like that here, above), my routines no longer produce corrupted filenames for the saved plots. The trouble seems to be caused by my how I read-in the file name. Here is a simple example that produces a corrupted file name for the saved plot: plot(1:10, xlab = a, ylab = â) file.name - file.choose() print(file.name) file.label - basename(file.name) savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) The name of my input Excel file is EXAMPLE 1 â vs a.xls The problem does not occur on R R2.7.0 I am running R2.7.2 on a 5 year old DELL box (2 Gig RAM, 3GHz Pentium 4) with Windows XP, and have also experienced the problem on my Thinkpad laptop (2 Gig, Intel Core2 Duo, 1.6GHz) running Vista. Thank you for your counsel. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 4:39 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: Re: [R] trouble with character \u00e2 You haven't given any of the information asked for in the posting guide. But, assuming this is Windows in CP1252 (as I believe that has been your locale before), it works for me in current R. plot(1:10) file.label - foo savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) If you are not using 2.8.0 beta or 2.7.2 patched, please check those. This might be related to o file.path() did not work correctly in 2.7.0 if the components had different encodings. (NEWS for 2.7.1). On Sun, 5 Oct 2008, Charles Annis, P.E. wrote: Greetings R-wizards: For historical reasons I have filenames with the character â and have successfully used \u00e2 in its place, with the hoped-for result on all my on-screen plots. However since R2.7.0 I have trouble with savePlot() when the file name includes that character as it does in this example: savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) In R2.6.0 and earlier, R would ignore a dot ('.') in the file name and supply the extension. Since R2.7.0 if filename does include a dot, savePlot() will not add the file type as an extension. Thus my apparent redundancy in the file name. The problem I have is that the example command will substitute an unwanted character for â, yet if I use File, save as, jpg ... and type in a name containing the troublesome character, R saves the on-screen plot with that character in the name with no complaints. I have tried using iconv() with no success, as can be seen with the following code: file.name - paste(diagnostic â vs a , file.label, .jpg, sep = ) iconv.List - iconvlist() for(encoding in iconv.List) { print(iconv(file.name, , encoding, ))} So, here's the question: How can I save, with a non-interactive R command, an existing plot with the troublesome character in the file name? Thanks. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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 -- 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
Re: [R] Suspicious output from lme4-mcmcsamp
De Woody J.A. j.dewoody at soton.ac.uk writes: For instance: fm1 - lmer(Reaction ~ Days + (Days|Subject), sleepstudy) sm1 - mcmcsamp(fm1, 5000) Error in .local(object, n, verbose, ...) : Code for non-trivial theta_T not yet written Douglas Bates mentions this as a reminder to himself to write the code. http://article.gmane.org/gmane.comp.lang.r.lme4.devel/1386 Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] histogram loses top row with alpha transparency under Windows
Hello all. Trying to use transparency for overlaid histogram plots I have come across an interesting inconsistency, possibly a bug when running under Windows. Originally noticed in R 2.7.1, it is still there in 2.8.0 beta. library(lattice) zz - function(n,alpha) { ranges - NULL for(ds in 1:n){ ranges - rbind(ranges,data.frame(confidence=c(0,100),dataset=as.character(ds),cor rect=c(FALSE,TRUE))) } panel.colhist = function(x, group.number, col, ...) { panel.histogram(x, col=group.number+1, ...) } x - histogram(~confidence|dataset,data=ranges,alpha=alpha, panel=panel.superpose,panel.groups=panel.colhist,groups=correct) print(x) } zz(12,1) # works as expected, 12 identical plots zz(12,0.5) # top row of plots has no bars at all, lower rows are as expected zz(1,1) # two bars fine zz(1,0.5) # no bars at all (I also find the default breaks slightly counter-intuitive here, as the number of breaks seems to depend on the total size of the data, rather than on the size within each plot - the bars meet in the zz(1,1) case but are well separated in the zz(12,1) case.) I am running on 64-bit Windows Vista Business SP1, session info is as follows: R version 2.8.0 beta (2008-10-07 r46631) i386-pc-mingw32 locale: LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-15 loaded via a namespace (and not attached): [1] grid_2.8.0 It appears to work correctly under (Suse) linux, with the following session characteristics: R version 2.7.2 (2008-08-25) i686-pc-linux-gnu locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.U TF-8;LC_MONETARY=C;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME= C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATI ON=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] lattice_0.17-13 loaded via a namespace (and not attached): [1] grid_2.7.2 sysnamerelease Linux2.6.22.18-0.2-default version nodename #1 SMP 2008-06-09 13:53:20 +0200 node76 machine login i686 kponting user kponting Keith Ponting Aurix Ltd, Malvern WR14 3SZ UK __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] par(new = TRUE) - overplotting
Hi everybody, I want to create some boxplots (as png) within an lapply method. To get nice gridlines behind the boxplot, I plotted it twice and therefore I set par(new=TRUE). This works nicely for the first plot but the second does plot on the first plot too and creates a mess... How can I force to start with a blank plot again??? lapply(c(1,2), FUN=function(i) { png(filename = test.png, width = 450, height = 600) gridlines - seq(0.1,2.0,0.1) par(mar=c(12, 4, 5, 2)) bpars - list(yaxt = n, las = 2 ) boxplot(mydata[i], pars= bpars ) abline(h = gridlines, col=lightgray, lty=2) abline(h = 1, col=red, lwd=3) par(new=TRUE) boxplot(mydata[i], pars= bpars, main = title) dev.off() }) Ciao, Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in spdep: system is computationally singular
Hi all, I am trying to run an autologistic model using the function errorsarlm from spdep package. **I built an XY matrix extracting the two colums from matriz** coords1-matriz[matriz$casos1==1, c(4,5)] coords1-as.matrix(coords1) **I identify neighbours of region points** nb20-dnearneigh(coords1,0,20,longlat=TRUE) ** I build a neighbours list with spatial weights** nb20.w-nb2listw(nb20, glist=NULL, style=W, zero.policy=TRUE) **I run a glm** glm1-glm(matriz$sp~poly(matriz$iso,3)+poly(matriz$tmax,3)+poly(matriz$mdr,3)+poly(matriz$twq,3)+poly(matriz$tmin,3)+poly(matriz$pdq,3)+poly(matriz$trng,3),data=matriz, subset=matriz$casos10, family=binomial) glm.scope-list(var1=~1+iso+poly(iso,2)+poly(iso,3),var2=~1+tmax+poly(tmax,2)+poly(tmax,3),var3=~1+mdr+poly(mdr,2)+poly(mdr,3),var4=~1+twq+poly(twq,2)+poly(twq,3),var5=~1+tmin+poly(tmin,2)+poly(tmin,3),var6=~1+pdq+poly(pdq,2)+poly(pdq,3),var7=~1+trng+poly(trng,2)+poly(trng,3),var8=~1+mdr+poly(mdr,2)+poly(mdr,3)) final.glm1-step.gam(glm1,glm.scope,direction=back) **I want to estimate the spatial simultaneous autoregressive error model** res20-errorsarlm(finalglm1, listw=nb20.w, zero.policy=TRUE) But here I receive the following error message: Error in solve.default(asyvar, tol = tol.solve) : system is computationally singular: reciprocal condition number = 2.8713e-12 What is happening? What does this message mean? Thanks a lot, Alberto --- Alberto Jiménez-Valverde Natural History Museum and Biodiversity Research Center The University of Kansas Lawrence, Kansas 66045 USA email 1: [EMAIL PROTECTED] email 2: [EMAIL PROTECTED] CV: http://www.biogeografia.com/CV/ajimenez/albertojimenezvalverde.htm [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rgl_081.708: rgl.snapshot fails, causing persistent problems
*Summary*: The latest Windows binary version of rgl_081.708 from R-Forge has some problem that causes rgl.snapshot() to fail, at least on my system. Thereafter, *all* rgl 3D graphics are rendered without any text labels. The last problem remains even after (a) removing rgl and re-installing from CRAN, (b) re-starting with a fresh installation of all of R 2.7.2. *System*: Win XP Pro A vexing and persistent problem arose after I installed rgl_081.708 from R-Forge via install.packages(rgl,repos=http://R-Forge.R-project.org;) Everything worked fine until the *first* time I tried to take a rgl.snapshot() of the current scene. rgl.snapshot(test.png) [1] failed OK, I did : remove.packages(rgl) install.packages(rgl) to get rgl_081 from CRAN However, after that, snapshot works, but all rgl.text -- axis labels, tick labels, plot annotations, etc. do not appear. E.g.: see http://euclid.psych.yorku.ca/SCS/Gallery/Test/iris3d-bad.jpg produced by: library(rgl) data(iris) col -c(blue, green, red)[iris$Species] plot3d(iris[,1:3], type=s, size=0.4, col=col, cex=2, box=FALSE, aspect=iso) (There should be variable labels and tick labels for the axes.) I've now tried everything I can think of, *both* with R 2.7.2 and R 2.7.1 - quitting and restarting R - uninstalling R, and re-installing a fresh copy, with all my old libraries (rgl_081) - reboot and power-down/restart The problem persists, and I don't know what to look for to try to track this down and fix it. Some questions: What might cause this to persist, even after reinstalling R? Could there be any interaction between rgl.dll and anything else on my system? Is anyone brave enough to see if this problem [with rgl_081.708] is reproducible? If not reproducible, then it is something on my system. If it is, could there be a problem with the build process on R-Forge for building rgl with png support? I've contacted the package maintainer, but he has no suggestions. R sessionInfo() R version 2.7.2 (2008-08-25) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] foreign_0.8-29 rgl_0.81 heplots_0.8-0 car_1.2-8 loaded via a namespace (and not attached): [1] tools_2.7.2 R -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
Thank you Professor: After reading in the file this is what I see: file.label [1] EXAMPLE 1 â vs a.xls charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 Encoding(file.label) [1] UTF-8 Encoding(paste(diagnostic â vs a , file.label, .jpg, sep = )) [1] UTF-8 But look what happens after I run your example: charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 e2 20 76 73 20 61 2e 78 6c 73 (after) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 (before) The file label appears on the screen as it does above both times, but clearly charToRaw() shows that the coding for â has changed from the unexpected c3 a2, to the desired e2. After running your example I now observe Encoding(file.label) [1] latin1 Again, thank you for your help. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 10:32 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: RE: [R] trouble with character \u00e2 That also works without a hitch on my box, even in vanilla 2.7.2. What exactly is in file.label as given by charToRaw(file.label) Encoding(file.label) ? It should be in UTF-8, and so should paste(diagnostic â vs a , file.label, .jpg, sep = ) It looks like the latter is not being treated as UTF-8 on your system (see what Encoding() says on its value). On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you, Professor Ripley: Your example works for me too. plot(1:10, xlab = a, ylab = â) file.label - EXAMPLE 1 â vs a.xls savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) But, if I read-in the file name using file.choose() I get the same corrupted output filename ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ) from my R routines. However, if I paste that same file.label as it is printed to the screen with my input routine, replacing your foo (as above) things work as they should ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ). Furthermore, if I again run my plotting routines after your example (like that here, above), my routines no longer produce corrupted filenames for the saved plots. The trouble seems to be caused by my how I read-in the file name. Here is a simple example that produces a corrupted file name for the saved plot: plot(1:10, xlab = a, ylab = â) file.name - file.choose() print(file.name) file.label - basename(file.name) savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) The name of my input Excel file is EXAMPLE 1 â vs a.xls The problem does not occur on R R2.7.0 I am running R2.7.2 on a 5 year old DELL box (2 Gig RAM, 3GHz Pentium 4) with Windows XP, and have also experienced the problem on my Thinkpad laptop (2 Gig, Intel Core2 Duo, 1.6GHz) running Vista. Thank you for your counsel. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 4:39 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: Re: [R] trouble with character \u00e2 You haven't given any of the information asked for in the posting guide. But, assuming this is Windows in CP1252 (as I believe that has been your locale before), it works for me in current R. plot(1:10) file.label - foo savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) If you are not using 2.8.0 beta or 2.7.2 patched, please check those. This might be related to o file.path() did not work correctly in 2.7.0 if the components had different encodings. (NEWS for 2.7.1). On Sun, 5 Oct 2008, Charles Annis, P.E. wrote: Greetings R-wizards: For historical reasons I have filenames with the character â and have successfully used \u00e2 in its place, with the hoped-for result on all my on-screen plots. However since R2.7.0 I have trouble with savePlot() when the file name includes that character as it does in this example: savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) In R2.6.0 and earlier, R would ignore a dot ('.') in the file name and supply the extension. Since R2.7.0 if filename does include a dot, savePlot() will not add the file type as an extension. Thus my apparent redundancy in the file name. The problem I have is that the example command will substitute an unwanted character for â, yet if I use File, save as, jpg ... and type in a name containing the troublesome character, R saves the on-screen plot with that character in the name with no complaints. I have tried using iconv() with no success, as can be seen with the following code: file.name - paste(diagnostic â vs a , file.label, .jpg, sep = )
[R] ParallelR
Anyone using or has access to ParallelR? I was looking at the page and found nothing really useful! http://www.revolution-computing.com/sitegenius/topic.php?id=195 I want to see if I can run R on a cluster of workstation, and use batch systems like Grid Engine or Xgrid: http://gridengine.sunsource.net/ http://ww.apple.com/acg/xgrid/ --Chi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to join the two tables based on one overlapped column
Dear list, I need some clues on this. I have two excel files and I basically want to map one to the other one. Can you give me some hints how to do it? The first excel file, named as Susan_probe.xls, there are two columns, PROBE_ID1 and SEARCH_KEY1 PROBE_ID1 SEARCH_KEY1 ILMN_30212 ILMN_30212 ILMN_1285 ILMN_1285 ILMN_137964 ILMN_137964 ILMN_138109 ILMN_138109 ... The second excel file, named as John_probe.xls, there are two columns as well, PROBE_ID2 and SEARCH_KEY2. PROBE_ID2 SEARCH_KEY2 ILMN_1809034 ILMN_16367 ILMN_1660305 ILMN_16583 ILMN_1792173 ILMN_19158 ... There are 46713 rows in the first excel file and 49702 rows in the second file. Probes in the first columns of two excel files are different but they can be matched based on the second column SEARCH_KEY. So what I want to do is to substitute the PROBE_ID1 in the Susan_probe.xls file with the PROBE_ID2 in the John_probe.xls based on their common SEARCH_KEY. Thank you so much for your help. I really appreciate. All the best, Allen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to join the two tables based on one overlapped column
dataToMerge=data.frame(yourtablename2$PROBE_ID2, yourtablename2$SEARCH_KEY2) ##Puts the two columns of interest in dataset 2 in a separate data frame. mergedData=merge(yourtablename1,dataToMerge,by.x=SEARCH_KEY1,by.y=SEARCH_KEY 2,all.x=T,all.y=F) ##merges the first table with the data frame just created looking for matches between SEARCH_KEY1 and SEARCH_KEY2, all entries in dataset 1 are retained (whether matched or not), entries in the dataToMerge dataframe that do not match any entries in dataset 1 are dropped. You then have an additional column in mergedData that contains the PROBE_ID2 and you can just assign them to PROBE_ID1 (i.e. replace PROBE_ID1 by the values in this column). Cheers, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von ss Gesendet: Wednesday, October 08, 2008 11:33 AM An: R help Betreff: [R] How to join the two tables based on one overlapped column Dear list, I need some clues on this. I have two excel files and I basically want to map one to the other one. Can you give me some hints how to do it? The first excel file, named as Susan_probe.xls, there are two columns, PROBE_ID1 and SEARCH_KEY1 PROBE_ID1 SEARCH_KEY1 ILMN_30212 ILMN_30212 ILMN_1285 ILMN_1285 ILMN_137964 ILMN_137964 ILMN_138109 ILMN_138109 ... The second excel file, named as John_probe.xls, there are two columns as well, PROBE_ID2 and SEARCH_KEY2. PROBE_ID2 SEARCH_KEY2 ILMN_1809034 ILMN_16367 ILMN_1660305 ILMN_16583 ILMN_1792173 ILMN_19158 ... There are 46713 rows in the first excel file and 49702 rows in the second file. Probes in the first columns of two excel files are different but they can be matched based on the second column SEARCH_KEY. So what I want to do is to substitute the PROBE_ID1 in the Susan_probe.xls file with the PROBE_ID2 in the John_probe.xls based on their common SEARCH_KEY. Thank you so much for your help. I really appreciate. All the best, Allen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ParallelR
Hi! Have you looked at snow, snowfall, Rmpi, or rparallel, please? Hope this helps, Sincerely, Erin On Wed, Oct 8, 2008 at 10:14 AM, Chi Chan [EMAIL PROTECTED] wrote: Anyone using or has access to ParallelR? I was looking at the page and found nothing really useful! http://www.revolution-computing.com/sitegenius/topic.php?id=195 I want to see if I can run R on a cluster of workstation, and use batch systems like Grid Engine or Xgrid: http://gridengine.sunsource.net/ http://ww.apple.com/acg/xgrid/ --Chi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] par(new = TRUE) - overplotting
Antje niederlein-rstat at yahoo.de writes: I want to create some boxplots (as png) within an lapply method. To get nice gridlines behind the boxplot, I plotted it twice and therefore I set par(new=TRUE). This works nicely for the first plot but the second does plot on the first plot too and creates a mess... How can I force to start with a blank plot again??? lapply(c(1,2), FUN=function(i) { png(filename = test.png, width = 450, height = 600) gridlines - seq(0.1,2.0,0.1) par(mar=c(12, 4, 5, 2)) bpars - list(yaxt = n, las = 2 ) boxplot(mydata[i], pars= bpars ) abline(h = gridlines, col=lightgray, lty=2) abline(h = 1, col=red, lwd=3) par(new=TRUE) boxplot(mydata[i], pars= bpars, main = title) dev.off() }) I do not fully understand what you want to do, but in each case you overwrite your files. Try something like: png(filename = paste(test,i,.png), width = 450, height = 600) and think over again why you need the par(new=TRUE). And please, make your examples self-running, for example by adding mydata = rnorm(100) even if you probably have more complex data. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme and lmer df's and F-statistics again
Hm. Bert Gunter wrote: that even the most technical aspects of the discipline can be made manifest to anyone with half a brain and a stat 101 course under their belt. I don't think this is something I can use in a rebuttal. The reviewer may be offended and reviewers are people one does not want to offend. In general, I disagree. This get a bit philosophical, but well. I think there are some occasions where it is important to explain complicated things in few, easy to understand sentences to laymen (even if that means loss of preciseness). That has to be done (and was done in the past) with the other examples you give (thermodynamics, Krebs cycle ect.) fairly often, especially when politics are involved (think LHC, stem cells, or, even the structure of the DNA). Even for very difficult topics this needs to be done. I think our (maybe most challenging) duty as researchers paid by tax money is also to explain our sometimes very complicated research to laymen in an easy understandable manner. Albeit it is of course not your duty to explain it to me on this list, if you are offended by my attitude. Isn't it the most normal thing to ask for an explanation when somebody doesn't understand something? I've learned that asking is a good way of learning new things. Sorry if that offended you. Confused, Julia Cheers, Julia -- View this message in context: http://www.nabble.com/lme-and-lmer-df%27s-and-F-statistics-again-tp19835361p19877014.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rgl_081.708: rgl.snapshot fails, causing persistent problems
Dear Michael, I haven't tried rgl.snapshot() in the development version of rgl, so I can't comment on that, but I believe that these are two unrelated problems. I think that the version of rgl on CRAN fails to display text when rgl.* and *3d function calls are mixed, while this works in the development version. I hope this helps, John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Friendly Sent: October-08-08 10:54 AM To: R-Help Subject: [R] rgl_081.708: rgl.snapshot fails, causing persistent problems *Summary*: The latest Windows binary version of rgl_081.708 from R-Forge has some problem that causes rgl.snapshot() to fail, at least on my system. Thereafter, *all* rgl 3D graphics are rendered without any text labels. The last problem remains even after (a) removing rgl and re-installing from CRAN, (b) re-starting with a fresh installation of all of R 2.7.2. *System*: Win XP Pro A vexing and persistent problem arose after I installed rgl_081.708 from R-Forge via install.packages(rgl,repos=http://R-Forge.R-project.org;) Everything worked fine until the *first* time I tried to take a rgl.snapshot() of the current scene. rgl.snapshot(test.png) [1] failed OK, I did : remove.packages(rgl) install.packages(rgl) to get rgl_081 from CRAN However, after that, snapshot works, but all rgl.text -- axis labels, tick labels, plot annotations, etc. do not appear. E.g.: see http://euclid.psych.yorku.ca/SCS/Gallery/Test/iris3d-bad.jpg produced by: library(rgl) data(iris) col -c(blue, green, red)[iris$Species] plot3d(iris[,1:3], type=s, size=0.4, col=col, cex=2, box=FALSE, aspect=iso) (There should be variable labels and tick labels for the axes.) I've now tried everything I can think of, *both* with R 2.7.2 and R 2.7.1 - quitting and restarting R - uninstalling R, and re-installing a fresh copy, with all my old libraries (rgl_081) - reboot and power-down/restart The problem persists, and I don't know what to look for to try to track this down and fix it. Some questions: What might cause this to persist, even after reinstalling R? Could there be any interaction between rgl.dll and anything else on my system? Is anyone brave enough to see if this problem [with rgl_081.708] is reproducible? If not reproducible, then it is something on my system. If it is, could there be a problem with the build process on R-Forge for building rgl with png support? I've contacted the package maintainer, but he has no suggestions. R sessionInfo() R version 2.7.2 (2008-08-25) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] foreign_0.8-29 rgl_0.81 heplots_0.8-0 car_1.2-8 loaded via a namespace (and not attached): [1] tools_2.7.2 R -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme and lmer df's and F-statistics again
Hi there, thanks for your help. I did read Bates statement several times, and I am very glad and thankful that many statisticians spend much time on this. The problem is, as Dieter pointed it out, that many end users often have to use statistics without being able to fully understand the math behind it. Because if they would spend as much time on that as statisticians do, they wouldn't be able to do what they do where they use statistics for. And, no, I don't expect that a simple answer exists, but it might be that somebody had a similar problem like me before and may have a convincing line for a referee at hands. I have problems reformulating what I read here in my own words. Dieter: when you write: but to use lme instead when possible do you mean that when using lme the F-stats are correct? Because I assumed that the problem would be the same with lme. Julia -- View this message in context: http://www.nabble.com/lme-and-lmer-df%27s-and-F-statistics-again-tp19835361p19876728.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Space between bars in barplot
Hi, with the space parameter it is possible to change the gap / distance between the bars, but is it also possible to change the space after each 6th bar? So for example you have bars from 1 to 6 then a large gap and then the next six bars from 7 to 12 Thanks a lot! -- View this message in context: http://www.nabble.com/Space-between-bars-in-barplot-tp19878227p19878227.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
Another option is bargraph.CI or lineplot.CI from the package sciplot. See http://mutualism.williams.edu/sciplot for examples. On Tue, 2008-10-07 at 23:31 -0500, Michael Just wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. I've looked at lattice and gplots2, but given my beginner status my efforts are not propelling me very far. Thank you kindly, Michael Just [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://mutualism.williams.edu signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help for compile sjava
Dear duncan, I'm writing to ask you for some help about compiling SJava. I encounter some errors when I compiled SJava on Window XP: Building JNI header files... Extracting the classes from Environment.jar /jdk1.3/bin/jar: not found RForeignReference After executing command sh ./configure.win C:/Program Files/R/R-2.7.2, I modify the JAVA_HOME in file $RHOME/ library\SJava\ configure.win, $RHOME/ library\SJava\src\Makefile.win and $RHOME/ library\SJava\src\Makevars.win to my real JAVA_HOME D:/Java/jdk1.5.0_06. Then execute make pkg-SJava. But it is failed. And I could not find any other files included /jdk1.3/bin/jar by default. It is highly appreciated if you can give me some tips. Thanks. -- Sincerely yours, Jacky Huang JAVARUBY MONKEY CDC GuangZhou MSN: [EMAIL PROTECTED] Blog: http://www.open-ruby.com [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using grep
which(A %in% B) -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of mentor_ Sent: Wednesday, October 08, 2008 11:19 AM To: r-help@r-project.org Subject: [R] Using grep Hi, I have a vector A with (200, 201, 202, 203, 204, ... 210) and a vector B with (201, 204, 209). Now I would like to get the position in vector A matches with the entries in vector B So what I want to have is the following result: [1] 2 5 10 I tried the following: grep(B, A) grep(c(B), A) A - as.character(A) B - as.character(B) grep(B, A) grep(c(B), A) and several other combinations. But nothing is giving me the right result?! Does anyone know why? Cheers, Mentor -- View this message in context: http://www.nabble.com/Using-grep-tp19881017p19881017.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
On Tue, Oct 7, 2008 at 11:31 PM, Michael Just [EMAIL PROTECTED] wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. Here's an alternative suggestion - don't use bars, use dots. Bar plots with standard errors are sometime called dynamite plots (probably because they should be blown up). See http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/DynamitePlots and http://emdbolker.wikidot.com/blog:dynamite for some reasons not to use them and possible alternatives. I hope that package authors who provide methods to make these plots easy will reconsider. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using grep
Here is a possible solution: A [1] 200 201 202 203 204 205 206 207 208 209 210 B [1] 201 204 209 which(!is.na(match(A,B))) [1] 2 5 10 Hope this helps, Sincerely, Erin On Wed, Oct 8, 2008 at 10:19 AM, mentor_ [EMAIL PROTECTED] wrote: Hi, I have a vector A with (200, 201, 202, 203, 204, ... 210) and a vector B with (201, 204, 209). Now I would like to get the position in vector A matches with the entries in vector B So what I want to have is the following result: [1] 2 5 10 I tried the following: grep(B, A) grep(c(B), A) A - as.character(A) B - as.character(B) grep(B, A) grep(c(B), A) and several other combinations. But nothing is giving me the right result?! Does anyone know why? Cheers, Mentor -- View this message in context: http://www.nabble.com/Using-grep-tp19881017p19881017.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using grep
A - seq(200,210,1) B - c(201,204,209) which(A %in% B) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of mentor_ Sent: Wednesday, October 08, 2008 11:19 AM To: r-help@r-project.org Subject: [R] Using grep Hi, I have a vector A with (200, 201, 202, 203, 204, ... 210) and a vector B with (201, 204, 209). Now I would like to get the position in vector A matches with the entries in vector B So what I want to have is the following result: [1] 2 5 10 I tried the following: grep(B, A) grep(c(B), A) A - as.character(A) B - as.character(B) grep(B, A) grep(c(B), A) and several other combinations. But nothing is giving me the right result?! Does anyone know why? Cheers, Mentor -- View this message in context: http://www.nabble.com/Using-grep-tp19881017p19881017.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] extracting a subset of sublists form a list; vectorized form
Hello; I'll put my real problem through a simple example: I've got a main list: main.lst - lst() With a number of sublists: for(i in 1:1000){ main.lst[[i]] - list() main.lst[[i]]$first - runif(1,0,1) main.lst[[i]]$second - runif(2,3,4) } If later on I need to split this list, how could I extract several sublists in a vectorized form? For example, to extract the four first sublists, to be passed to a function, sintaxis like this won't work: sublist - main.lst[[1:4]] Although I could do sublist - list() for(i in 1:4){ sublist[[i]] - main.lst[[i]] } I would hope that a vectorized way could exist. Thanks, and regards, Javier --- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] rgl_081.708: rgl.snapshot fails, causing persistent problems
Thanks, John What you say about mixing rgl.* and *3d calls may be true, but that is not my problem. After this occurred, I tried many things, but reduced it to the smallest, most basic example (in my original post), using only plot3d(), that worked perfectly in both the CRAN and R-Forge versions, until the first time I used rgl.snapshot() with the development version. Unfortunately, I'm now in a position where I can't test whether snapshot3d() does not provoke this, because the basic *3d calls no longer work properly on my desktop machine. I'm reduced to working on my laptop to create images for an upcoming talk. -Michael John Fox wrote: Dear Michael, I haven't tried rgl.snapshot() in the development version of rgl, so I can't comment on that, but I believe that these are two unrelated problems. I think that the version of rgl on CRAN fails to display text when rgl.* and *3d function calls are mixed, while this works in the development version. I hope this helps, John -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Friendly Sent: October-08-08 10:54 AM To: R-Help Subject: [R] rgl_081.708: rgl.snapshot fails, causing persistent problems *Summary*: The latest Windows binary version of rgl_081.708 from R-Forge has some problem that causes rgl.snapshot() to fail, at least on my system. Thereafter, *all* rgl 3D graphics are rendered without any text labels. The last problem remains even after (a) removing rgl and re-installing from CRAN, (b) re-starting with a fresh installation of all of R 2.7.2. *System*: Win XP Pro A vexing and persistent problem arose after I installed rgl_081.708 from R-Forge via install.packages(rgl,repos=http://R-Forge.R-project.org;) Everything worked fine until the *first* time I tried to take a rgl.snapshot() of the current scene. rgl.snapshot(test.png) [1] failed OK, I did : remove.packages(rgl) install.packages(rgl) to get rgl_081 from CRAN However, after that, snapshot works, but all rgl.text -- axis labels, tick labels, plot annotations, etc. do not appear. E.g.: see http://euclid.psych.yorku.ca/SCS/Gallery/Test/iris3d-bad.jpg produced by: library(rgl) data(iris) col -c(blue, green, red)[iris$Species] plot3d(iris[,1:3], type=s, size=0.4, col=col, cex=2, box=FALSE, aspect=iso) (There should be variable labels and tick labels for the axes.) I've now tried everything I can think of, *both* with R 2.7.2 and R 2.7.1 - quitting and restarting R - uninstalling R, and re-installing a fresh copy, with all my old libraries (rgl_081) - reboot and power-down/restart The problem persists, and I don't know what to look for to try to track this down and fix it. Some questions: What might cause this to persist, even after reinstalling R? Could there be any interaction between rgl.dll and anything else on my system? Is anyone brave enough to see if this problem [with rgl_081.708] is reproducible? If not reproducible, then it is something on my system. If it is, could there be a problem with the build process on R-Forge for building rgl with png support? I've contacted the package maintainer, but he has no suggestions. R sessionInfo() R version 2.7.2 (2008-08-25) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] foreign_0.8-29 rgl_0.81 heplots_0.8-0 car_1.2-8 loaded via a namespace (and not attached): [1] tools_2.7.2 R -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html Toronto, ONT M3J 1P3 CANADA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Using grep
On 08-Oct-08 15:19:02, mentor_ wrote: Hi, I have a vector A with (200, 201, 202, 203, 204, ... 210) and a vector B with (201, 204, 209). Now I would like to get the position in vector A matches with the entries in vector B So what I want to have is the following result: [1] 2 5 10 First of all: A - (200:210) B-c(201, 204, 209) A # [1] 200 201 202 203 204 205 206 207 208 209 210 B # [1] 201 204 209 which(A %in% B) # [1] 2 5 10 as desired. I tried the following: grep(B, A) grep(c(B), A) A - as.character(A) B - as.character(B) grep(B, A) grep(c(B), A) and several other combinations. But nothing is giving me the right result?! Does anyone know why? In grep(pattern,x,...): pattern: character string containing a regular expression (or character string for 'fixed = TRUE') to be matched in the given character vector. Coerced by 'as.character' to a character string if possible. x, text: a character vector where matches are sought, or an object which can be coerced by 'as.character' to a character vector. you can clearly have 'x' as a vector of character strings, so your as.character(A) is valid for 'x'. But as.character(B) is neither a regular expression nor a character string -- it is a vector of character strings. So it is not valid for 'pattern'. What seems to happen here is that grep() takes the first element (201) of as.character(B), and uses this as the regular expression (or character string): grep(A,c(ABC,BCD,CDE,EAB)) # [1] 1 4 # (as expected) grep(c(A,B),c(ABC,BCD,CDE,EAB)) # [1] 1 4 # (the same as the previous; B in c(A,B) is ignored) Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 08-Oct-08 Time: 17:43:03 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
On Wednesday 08 October 2008, Manuel Morales wrote: Another option is bargraph.CI or lineplot.CI from the package sciplot. See http://mutualism.williams.edu/sciplot for examples. On Tue, 2008-10-07 at 23:31 -0500, Michael Just wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. I've looked at lattice and gplots2, but given my beginner status my efforts are not propelling me very far. Thank you kindly, Michael Just # Personally, this looks more informative to me: library(lattice) bwplot(len ~ supp | factor(dose), data=ToothGrowth, layout=c(3,1)) # and some people like this: require(Hmisc) bwplot(supp ~ len | factor(dose), data=ToothGrowth, layout=c(3,1), panel=panel.bpplot, datadensity=TRUE) -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme and lmer df's and F-statistics again
Julia S. wrote: Hi there, thanks for your help. I did read Bates statement several times, and I am very glad and thankful that many statisticians spend much time on this. The problem is, as Dieter pointed it out, that many end users often have to use statistics without being able to fully understand the math behind it. Because if they would spend as much time on that as statisticians do, they wouldn't be able to do what they do where they use statistics for. And, no, I don't expect that a simple answer exists, but it might be that somebody had a similar problem like me before and may have a convincing line for a referee at hands. I have problems reformulating what I read here in my own words. Dieter: when you write: but to use lme instead when possible do you mean that when using lme the F-stats are correct? Because I assumed that the problem would be the same with lme. Julia They aren't... And they can be badly wrong in some cases. At this stage, I think the best one can do is to get a feeling for whether the DF would be large and if so, convince the referee to accept an asymptotic chi-square test (Wald or LRT type). I think that the rationale for requiring authors to state the DF is not so much that journals believe in mighty SAS, but that they want to be able to catch completely wrong analyses, like when people compare two groups of each 5 rats and get a denominator DF of around 100 because there were 10 (correlated) measurements on each rat and no between-rats variation in the model. As for figuring out whether or not you have large DF; if you have a nearly balanced design. it might be worth looking into what aov() says would be the DF for the same model with balanced data. (And in any case, all DF-type corrections are in a sense wrong because they depend on 3rd and 4th moments of the Gaussian distribution, and your data probably aren't perfectly Gaussian.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help for compile sjava
Jacky -- Duncan has kindly allowed me to maintain SJava. A current version is not readily available, but I will provide you with some help off-list (and arrange for more public dissemination soon). Martin Jacky Huang wrote: Dear duncan, I'm writing to ask you for some help about compiling SJava. I encounter some errors when I compiled SJava on Window XP: Building JNI header files... Extracting the classes from Environment.jar /jdk1.3/bin/jar: not found RForeignReference After executing command sh ./configure.win C:/Program Files/R/R-2.7.2, I modify the JAVA_HOME in file $RHOME/ library\SJava\ configure.win, $RHOME/ library\SJava\src\Makefile.win and $RHOME/ library\SJava\src\Makevars.win to my real JAVA_HOME D:/Java/jdk1.5.0_06. Then execute make pkg-SJava. But it is failed. And I could not find any other files included /jdk1.3/bin/jar by default. It is highly appreciated if you can give me some tips. Thanks. -- Martin Morgan Computational Biology / Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: Arnold Building M2 B169 Phone: (206) 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
Thank you all for you suggestions. They are all helpful. However, I have come to a more fundamental problem. Preparing my data to even make such a graph. I thought I was ready. I will obviously need to find the n, mean, and confidence interval for my data before I can plot them. for some of these plots. I thought perhaps this data manipulation would be easily done in R, but perhaps I should do it elsewhere and then bring it into R. I have about 5000 rows about 30 columns in my csv. I need to find: mean, n, confidence interval for a to-be-made selection from the entire data set. I have tried: aggregate, subset, dat$col1=2, etc Clearer?: I want to select data from my dataset where column1=2. Then when plotting this data I want to group it by 2 values (out of 4) from column10. I know this is probably as clear as mud, thanks for you continuing patience. I would really appreciate any assistance you are able to provide me. My limited knowledge in R grows quite rapdily and things become so much more successful for me when I am granted tips and snippets of code form R users like you. Sincerely, Michael Just On Wed, Oct 8, 2008 at 11:25 AM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, Oct 7, 2008 at 11:31 PM, Michael Just [EMAIL PROTECTED] wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. Here's an alternative suggestion - don't use bars, use dots. Bar plots with standard errors are sometime called dynamite plots (probably because they should be blown up). See http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/DynamitePlots and http://emdbolker.wikidot.com/blog:dynamite for some reasons not to use them and possible alternatives. I hope that package authors who provide methods to make these plots easy will reconsider. Hadley -- http://had.co.nz/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
Can you please try a 2.8.0 beta build? I have a suspicion as to what might be going on, and it cannot happen there. If my guess is correct, nfile - paste(diagnostic â vs a , file.label, .jpg, sep = ) savePlot(path.expand(nfile), type=jpg) may work for you in 2.7.2 (but as I said, I wasn't able to reproduce this there). The crucial bit is to use path.expand() on the final file name: it will do nothing except ensure that the encoding is correct. On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you Professor: After reading in the file this is what I see: file.label [1] EXAMPLE 1 â vs a.xls charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 Encoding(file.label) [1] UTF-8 Encoding(paste(diagnostic â vs a , file.label, .jpg, sep = )) [1] UTF-8 But look what happens after I run your example: charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 e2 20 76 73 20 61 2e 78 6c 73 (after) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 (before) The file label appears on the screen as it does above both times, but clearly charToRaw() shows that the coding for â has changed from the unexpected c3 a2, to the desired e2. After running your example I now observe Encoding(file.label) [1] latin1 Again, thank you for your help. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 10:32 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: RE: [R] trouble with character \u00e2 That also works without a hitch on my box, even in vanilla 2.7.2. What exactly is in file.label as given by charToRaw(file.label) Encoding(file.label) ? It should be in UTF-8, and so should paste(diagnostic â vs a , file.label, .jpg, sep = ) It looks like the latter is not being treated as UTF-8 on your system (see what Encoding() says on its value). On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you, Professor Ripley: Your example works for me too. plot(1:10, xlab = a, ylab = â) file.label - EXAMPLE 1 â vs a.xls savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) But, if I read-in the file name using file.choose() I get the same corrupted output filename ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ) from my R routines. However, if I paste that same file.label as it is printed to the screen with my input routine, replacing your foo (as above) things work as they should ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ). Furthermore, if I again run my plotting routines after your example (like that here, above), my routines no longer produce corrupted filenames for the saved plots. The trouble seems to be caused by my how I read-in the file name. Here is a simple example that produces a corrupted file name for the saved plot: plot(1:10, xlab = a, ylab = â) file.name - file.choose() print(file.name) file.label - basename(file.name) savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) The name of my input Excel file is EXAMPLE 1 â vs a.xls The problem does not occur on R R2.7.0 I am running R2.7.2 on a 5 year old DELL box (2 Gig RAM, 3GHz Pentium 4) with Windows XP, and have also experienced the problem on my Thinkpad laptop (2 Gig, Intel Core2 Duo, 1.6GHz) running Vista. Thank you for your counsel. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 4:39 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: Re: [R] trouble with character \u00e2 You haven't given any of the information asked for in the posting guide. But, assuming this is Windows in CP1252 (as I believe that has been your locale before), it works for me in current R. plot(1:10) file.label - foo savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) If you are not using 2.8.0 beta or 2.7.2 patched, please check those. This might be related to o file.path() did not work correctly in 2.7.0 if the components had different encodings. (NEWS for 2.7.1). On Sun, 5 Oct 2008, Charles Annis, P.E. wrote: Greetings R-wizards: For historical reasons I have filenames with the character â and have successfully used \u00e2 in its place, with the hoped-for result on all my on-screen plots. However since R2.7.0 I have trouble with savePlot() when the file name includes that character as it does in this example: savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) In R2.6.0 and earlier, R would ignore a dot ('.') in the file name and supply the extension. Since R2.7.0 if filename does include a dot, savePlot() will not add the file type as an extension. Thus
[R] Observed responses in 'augPred' data frame - Wrong order ?
Dea-R community. I'd like to draw your attention to an issue I have recently encountered while doing my current data analysis. I've got an unexpected (to me) result from the command: augPred(lmList(my.object)), 'my.object' being a grouped data frame of class: class(my.object) [1] nfnGroupedData nfGroupedData groupedDatadata.frame The problem is more easily explained by showing these two to Trellis plot: plot(my.object,some_options) plot(augPred(lmList(my.object)),some_options) [link to output: http://www.palug.net/Members/jabba ] Clearly the problem is that the predictions are correct, but the responses in the ``original'' part of the augPred data frame are in the wrong order, i.e. the response order does not match the grouping factor order (not sure this is in correct English, sorry). Debugging the function 'augPred.lmList' I've managed to understand that the problem resides in the following function calls: debug(nlme:::augPred.lmList) fm1.lis - lmList(my.object) augPred(fm1.lis) debugging in: augPred.lmList(fm1.lis) debug: { . primary - getCovariate(data) . groups - getGroups(object) . orig - data.frame(primary,groups, getResponse(object)) . } This approach works well on other datasets, such us the Orthodont data, but not for mine because, i guess, my rows are not first ordered by subject (subject is my grouping factor). In fact: getGroups(fm1.lis)[1:5] [1] CBT.1 CBT.2 CBT.3 CBT.4 CBT.5 34 Levels: CBT.14 CBT.2 CBT.11 CBT.13 CBT.12 CBT.5 ... V.6 getResponse(fm1.lis)[1:5] CBT.1 CBT.1 CBT.1 CBT.1 CBT.2 3432292728 My question: is there a simple way to get the proper result (modify the dataset or modify the function)? RTFM responses are welcomed. My (humble?) opinion: Neither Pinheiro-Bates (2000) nor online documentation, report the need for a particular row order in the costruction of grouped data objects, and i think it should be better do not rely on it. Or, at least, to document it somewhere. I want to thank the R-core team and the entire R community for this amazingly efficient and versatile software, and i am very proud that the (not only) statistical state-of-the-art software have a ``gpl distribution'' (which have many desirable properties ;-) ). Cheers. +---+ |Relevant system information| +---+ R.version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 7.2 year 2008 month 08 day25 svn rev46428 language R version.string R version 2.7.2 (2008-08-25) sessionInfo() R version 2.7.2 (2008-08-25) i486-pc-linux-gnu locale: LC_CTYPE=it_IT;LC_NUMERIC=C;LC_TIME=it_IT;LC_COLLATE=it_IT;LC_MONETARY=C;LC_MESSAGES=it_IT;LC_PAPER=it_IT;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=it_IT;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] MASS_7.2-44 lattice_0.17-15 nlme_3.1-89 loaded via a namespace (and not attached): [1] grid_2.7.2 tools_2.7.2 -- Marco Barbàra - Undergraduate student in Statistics at the University of Palermo (Italy) - Only free-as-in-freedom software user - Emacs lover __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Quantiles of weighted sample
Hello! I am wondering if there is a function in R that returns quantiles of a weighted sample, i.e., a set of values, each coming with a different weight. The function quantile() does that only for the case when the weights are all equal. In other words, I am looking for a quantile function that applies to a discrete distribution specified by values and their probabilities. Thanks in advance. Best, Giovanni Petris -- Giovanni Petris [EMAIL PROTECTED] Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Quantiles of weighted sample
see http://www.nabble.com/weighted-quantiles-to19864562.html#a19865869 url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Oct 8, 2008, at 12:37 PM, Giovanni Petris wrote: Hello! I am wondering if there is a function in R that returns quantiles of a weighted sample, i.e., a set of values, each coming with a different weight. The function quantile() does that only for the case when the weights are all equal. In other words, I am looking for a quantile function that applies to a discrete distribution specified by values and their probabilities. Thanks in advance. Best, Giovanni Petris -- Giovanni Petris [EMAIL PROTECTED] Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Trouble with word-wrapping and other Tinn-R options
I'm running R 2.7.1 with Tinn-R 2.0.0.7 and Windows XP Professional. I have write privileges to the folders containing my R installation, my Tinn-R installation, and my Tinn-R initialization settings. I installed R first, followed by Tinn-R. I have modified my RProfile.site file (in Tinn-R, RConfigurePermanent). My previous installations of Tinn-R and R worked fine, but on a different computer (also Windows XP; probably R 2.7.1 and Tinn-R 2.0.0.5). I am now having trouble controlling Tinn-R options. I will be most grateful if someone can set me straight, especially with respect to item 1. 1) Turning on word-wrapping seems to have the desired effect when I use Tinn-R only for editing. OptionsApplicationWord wrap toggles on wrapping as it should. If I shut down Tinn-R, I find that the change is preserved in my Tinn.ini file (bwordwrap=1). If I restart Tinn-R, words wrap properly when I open an existing file or create a new one. To my great frustration, submitting a line of R code has the undesirable side-effect of immediately and permanently turning off word-wrapping. Neither I nor our computer support staff have a clue why. 2) I can make durable changes to some aspects of the color scheme, but not others. For example, I can change highlighting of the current line from the default yellow to green and the changes are preserved when I restart. In contrast, changes to the foreground or background color for TeX commands are lost. A subscriber previously asked about item 2, but decided the problem was a bug in Tinn-R 1.19.2.3: that explanation seems doubtful given subsequent development that has occurred. Thanks in advance for any help you can provide, Glen * Glen A. Sargeant, Ph.D. Research Wildlife Biologist/Statistician Northern Prairie Wildlife Research Center 8711 37th Street SE Jamestown, ND 58401 Phone: (701) 253-5528 E-mail: [EMAIL PROTECTED] FAX: (701) 253-5553 * [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R seven years ago
Hello everyone, As some may know, today Google unveiled its 2001 search index [1]. I was curious to see how was R like at that time, and was not disappointed. Compared to today's main page [2], seven years ago the page looked [3] a bit rudimentary, especially the graphic. (It is wort noting that structurally the pages are very similar.) What definitely changed is the `Contributed packages' section. Then R featured 29 contributed packages [4], while now it features 1500+ [5]. It was surprising to realize the growth of R during the past seven years. Regards, Liviu [1] http://www.google.com/search2001.html [2] http://www.r-project.org/ [3] http://web.archive.org/web/20010722202756/www.r-project.org/ [4] http://web.archive.org/web/20010525004023/cran.r-project.org/bin/macos/contrib/src/ [5] http://cran.at.r-project.org/web/packages/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Space between bars in barplot
mentor_ mentor_ at gmx.net writes: with the space parameter it is possible to change the gap / distance between the bars, but is it also possible to change the space after each 6th bar? So for example you have bars from 1 to 6 then a large gap and then the next six bars from 7 to 12 Space can be a vector, as the doc say. Try barplot(rnorm(100),space=1:10) for a nice effect. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitting weibull, exponential and lognormal distributions to left-truncated data.
The package 'eha' fits these distributions (and more) with general left truncation and right censoring, and also regression models a la survreg. Look at 'phreg' for parametric proportional hazards models and 'aftreg' for accelerated failure time models. In your case of no covariates, the two functions give (of course) identical results. Hth, Göran On Wed, Oct 8, 2008 at 1:09 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: On Wed, 8 Oct 2008, Gough Lauren wrote: Hi, Thank you very much for your reply. This seems to be working OK when fitting weibull and lognormal distributions. However, fitdistr now requires me to include start values: As documented. ltwei-function(x,shape,scale,log=FALSE){ + dweibull(x,shape,scale,log)/pweibull(1,shape,scale,lower=FALSE) + } ltweifit-fitdistr(x,ltwei) # x is observed data Error in fitdistr(x, ltwei) : 'start' must be a named list ltweifit-fitdistr(x,ltwei,start=list(shape=0.5,scale=0.5)) There were 34 warnings (use warnings() to see them) ltweifit shape scale 1.11108278 13.00703630 ( 0.01936651) ( 0.42897340) Is there anyway I can fit to truncated data without having to name start values? Alternatively, is there any recommended technique for choosing sensible start values? Not really, depends how heavy the truncation is. Further, when I try to fit an exponential distribution I get an error message: But a truncated exponential is just a shifted exponential and has one parameter -- you gave it two! Just fit an exponential to x-1. ltexp-function(x,rate,log=FALSE){ + dexp(x,rate,log)/pexp(1,rate,lower=FALSE) + } ltexpfit-fitdistr(x,ltexp) Error in fitdistr(x, ltexp) : 'start' must be a named list ltexpfit-fitdistr(x,ltexp,start=list(0.1)) Warning message: In optim(x = c(2.541609, 1.436143, 4.600524, 6.437174, 2.84974, : one-diml optimization by Nelder-Mead is unreliable: use optimize ltexpfit Error in dn[[2]] : subscript out of bounds This error message seems to occur regardless of the start value used. Do you know why this is? Sorry to pester you again, and apologies if I am asking silly questions - my knowledge of R and probability distributions (except the normal!) are rather limited! Best wishes Lauren -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: 07 October 2008 12:25 To: [EMAIL PROTECTED] Cc: Gough Lauren; vito muggeo; r-help@r-project.org Subject: Re: [R] Fitting weibull, exponential and lognormal distributions to left-truncated data. On Tue, 7 Oct 2008, [EMAIL PROTECTED] wrote: I have several datasets, all left-truncated at x=1, that I am attempting to fit distributions to (lognormal, weibull and exponential). I had been using fitdistr in the MASS package as follows: A possible solution is to use the survreg() in the survival package without specifying the covariates, i.e. library(survival) survreg(Surv(..)~1, dist=weibull) where Surv(..) accepts information about times, censoring/truncation variables and dist allows to specify alternative distributions. See ?Surv e ?survreg The survival package is mostly targeted at right-censored data. The NADA package provides wrappers for many of the survival routines so they work with left-censored data. Left-censoring and left-truncation are not the same thing. With left-censoring you see that you had observations 1, and with left-truncation you do not (at least how the terms are usually applied: occasionally the meanings are reversed). For left-truncation it is relatively easy, e.g. ltwei - function(x, shape, scale = 1, log = FALSE) dweibull(x, shape, scale, log)/pweibull(1, shape, scale, lower=FALSE) and use this in fitdistr. -- 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 This message has been checked for viruses but the contents of an attachment may still contain software viruses, which could damage your computer system: you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Göran Broström
Re: [R] extracting a subset of sublists form a list; vectorized form
Dear Javier, sublists, to be passed to a function, sintaxis like this won't work: sublist - main.lst[[1:4]] are you looking for: sublist - main.lst[1:4] HTH Claudia __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Axes limits in rgl.surface (again)
An earlier post asked about limiting the z-axis range. I have the opposite problem. I need to expand the z-axis range in order to reduce the vertical relief on the surface plot (i.e. make it flatter). Any suggestions on how to do that? Kevin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R seven years ago
On 08-Oct-08 18:00:27, Liviu Andronic wrote: Hello everyone, As some may know, today Google unveiled its 2001 search index [1]. I was curious to see how was R like at that time, and was not disappointed. Compared to today's main page [2], seven years ago the page looked [3] a bit rudimentary, especially the graphic. (It is wort noting that structurally the pages are very similar.) What definitely changed is the `Contributed packages' section. Then R featured 29 contributed packages [4], while now it features 1500+ [5]. It was surprising to realize the growth of R during the past seven years. Regards, Liviu [1] http://www.google.com/search2001.html [2] http://www.r-project.org/ [3] http://web.archive.org/web/20010722202756/www.r-project.org/ [4] http://web.archive.org/web/20010525004023/cran.r-project.org/bin/macos/c ontrib/src/ [5] http://cran.at.r-project.org/web/packages/ Many thanks for this, Liviu! One might also compare the mailing list usage: [R-help 1997]: 484 messages [R-help 2001]: 4309 messages [R-help 2007]: 26250 1721+1909+2196+2145+2210+2309+ 2142+2246+2028+2711+2602+2031 So we now get more posts in a week than we did in the whole of 1997! Best wishes, Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 08-Oct-08 Time: 19:34:28 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R seven years ago
On Wed, 8 Oct 2008, Liviu Andronic wrote: Hello everyone, As some may know, today Google unveiled its 2001 search index [1]. I was curious to see how was R like at that time, and was not disappointed. Compared to today's main page [2], seven years ago the page looked [3] a bit rudimentary, especially the graphic. (It is wort noting that structurally the pages are very similar.) What definitely changed is the `Contributed packages' section. Then R featured 29 contributed packages [4], while now it features 1500+ [5]. It was surprising to realize the growth of R during the past seven years. But that is misleading: there may have been 29 binary Mac builds (in May, not Jan 2001?). In May 2001 according to tests/internet.Rout.save there were 106 source packages on CRAN. (Back then virtually all were available as Windows binaries but relatively few as MacOS9 binaries. And all were built by hand.) Another way to look at the growth of R is that the tarball for R 1.2.1 in early 2001 was 3.4Mb, and current tarballs (admittedly including ca 3.5Mb of recommended packages) are ca 16Mb. Regards, Liviu [1] http://www.google.com/search2001.html [2] http://www.r-project.org/ [3] http://web.archive.org/web/20010722202756/www.r-project.org/ [4] http://web.archive.org/web/20010525004023/cran.r-project.org/bin/macos/contrib/src/ [5] http://cran.at.r-project.org/web/packages/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R seven years ago
(Ted Harding) wrote: On 08-Oct-08 18:00:27, Liviu Andronic wrote: Hello everyone, As some may know, today Google unveiled its 2001 search index [1]. I was curious to see how was R like at that time, and was not disappointed. Compared to today's main page [2], seven years ago the page looked [3] a bit rudimentary, especially the graphic. (It is wort noting that structurally the pages are very similar.) What definitely changed is the `Contributed packages' section. Then R featured 29 contributed packages [4], while now it features 1500+ [5]. It was surprising to realize the growth of R during the past seven years. Regards, Liviu [1] http://www.google.com/search2001.html [2] http://www.r-project.org/ [3] http://web.archive.org/web/20010722202756/www.r-project.org/ [4] http://web.archive.org/web/20010525004023/cran.r-project.org/bin/macos/c ontrib/src/ [5] http://cran.at.r-project.org/web/packages/ Many thanks for this, Liviu! One might also compare the mailing list usage: [R-help 1997]: 484 messages [R-help 2001]: 4309 messages [R-help 2007]: 26250 1721+1909+2196+2145+2210+2309+ 2142+2246+2028+2711+2602+2031 So we now get more posts in a week than we did in the whole of 1997! Those not present at the useR in Dortmund might want to skim John Fox's talk http://www.statistik.uni-dortmund.de/useR-2008/slides/Fox.pdf (Actually, he did something at the end to avoid ending on a negative note. Flipped back to one of the increasing graphs, I suppose.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
Thank you Professor: Here is an example using R2.8.0 beta. It shows the coding to be latin1 I installed my package which requires rcom, RODBC, RColorBrewer, survival I was unable to find rcom in the packages drop-down menu. I tried mirrors USA(PA) and USA(PA2). rcom does appear in the menu run under R2.7.2, however. __ R version 2.8.0 beta (2008-10-07 r46631) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. ls() character(0) file.label - EXAMPLE 1 â vs a.xls charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 e2 20 76 73 20 61 2e 78 6c 73 Encoding(file.label) [1] latin1 Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 2:20 PM To: Charles Annis, P.E. Subject: RE: [R] trouble with character \u00e2 On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Professor Ripley: Can I get the Windows binaries for R2.8.0 beta? I looked earlier today and found the tar files but not any binaries. http://cran.r-project.org/src/base-prerelease/ http://cran.r-project.org/bin/windows/base/rtest.html or look via Windows. Thank you. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 1:10 PM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: RE: [R] trouble with character \u00e2 Can you please try a 2.8.0 beta build? I have a suspicion as to what might be going on, and it cannot happen there. If my guess is correct, nfile - paste(diagnostic â vs a , file.label, .jpg, sep = ) savePlot(path.expand(nfile), type=jpg) may work for you in 2.7.2 (but as I said, I wasn't able to reproduce this there). The crucial bit is to use path.expand() on the final file name: it will do nothing except ensure that the encoding is correct. On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you Professor: After reading in the file this is what I see: file.label [1] EXAMPLE 1 â vs a.xls charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 Encoding(file.label) [1] UTF-8 Encoding(paste(diagnostic â vs a , file.label, .jpg, sep = )) [1] UTF-8 But look what happens after I run your example: charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 e2 20 76 73 20 61 2e 78 6c 73 (after) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 (before) The file label appears on the screen as it does above both times, but clearly charToRaw() shows that the coding for â has changed from the unexpected c3 a2, to the desired e2. After running your example I now observe Encoding(file.label) [1] latin1 Again, thank you for your help. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 10:32 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: RE: [R] trouble with character \u00e2 That also works without a hitch on my box, even in vanilla 2.7.2. What exactly is in file.label as given by charToRaw(file.label) Encoding(file.label) ? It should be in UTF-8, and so should paste(diagnostic â vs a , file.label, .jpg, sep = ) It looks like the latter is not being treated as UTF-8 on your system (see what Encoding() says on its value). On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you, Professor Ripley: Your example works for me too. plot(1:10, xlab = a, ylab = â) file.label - EXAMPLE 1 â vs a.xls savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) But, if I read-in the file name using file.choose() I get the same corrupted output filename ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ) from my R routines. However, if I paste that same file.label as it is printed to the screen with my input routine, replacing your foo (as above) things work as they should ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ). Furthermore, if I again run my plotting routines after your example (like that here, above), my
Re: [R] Axes limits in rgl.surface (again)
On 10/8/2008 2:28 PM, Kevin Wright wrote: An earlier post asked about limiting the z-axis range. I have the opposite problem. I need to expand the z-axis range in order to reduce the vertical relief on the surface plot (i.e. make it flatter). Any suggestions on how to do that? persp3d supports a zlim argument to set the bounding box, but it doesn't make sense to ask rgl.surface to do that. It's a low level function to add a surface to a scene, it knows nothing about the scene as a whole. I don't recommend mixing rgl.* functions with *3d functions, either: you will get weird things happening (disappearing text, strange colours). Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram colours in lattice.
On 8/10/2008, at 5:16 PM, Deepayan Sarkar wrote: On 10/7/08, Rolf Turner [EMAIL PROTECTED] wrote: I am trying to do a histogram lattice plot and I would like the histogram to be filled with a different colour in each panel. Note: I want every bar in each histogram to be the same colour, but that there should be different colours *between* histograms. Can't seem to get this to work. I thought that something like the following would be a goer: set.seed(42) X - rnorm(200) A - factor(sample(letters[1:5],200,TRUE)) DF - data.frame(x=X,a=A) print(histogram(~x|a,data=DF,col=2:6,type=count, panel=function(x,...,subscripts,col) { panel.histogram(x,...,col=col[subscripts]) })) However it somewhat mysteriously colours the first bar/rectangle of the histogram appropriately in the last three panels, leaving all of the others blank, and leaves all bars blank in the first two panels. That's because you are ending up with 'col[subscripts]' being a vector, most elements of which are NA. Can I do what I want? How? print(histogram(~x|a,data=DF,col=2:6,type=count, panel=function(x,...,col) { panel.histogram(x,...,col=col[packet.number()]) })) Works like a charm. Thanks very much. I guess I thought I roughly understood what ``subscripts'' meant, and it seems I don't understand at all. And I didn't know *anything* about ``packet.number()''. It would seem that I need to read your book --- are these things explained there? Thanks again. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question from Braun/Murdoch book
On 8/10/2008, at 6:48 PM, Erin Hodgess wrote: Hi R People: I am looking at the Braun/Murdoch book, A First Course in Statistical Programming in R, and I have a question about a function there. It's on page 52, Example 4.5; the sieve of Erastosthenes. There is a line: primes - c() Is there a difference between using that and primes - NULL please? When you put in primes - c(), primes comes back as NULL. Is one more efficient or is this just a matter of programming style, please? I think that using primes - c() rather than primes - NULL is a load of dingos' kidneys. ;-) [Hi John!!!] cheers, Rolf ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lme and lmer df's and F-statistics again
On 9/10/2008, at 12:34 AM, Julia S. wrote: Hm. Bert Gunter wrote: that even the most technical aspects of the discipline can be made manifest to anyone with half a brain and a stat 101 course under their belt. I don't think this is something I can use in a rebuttal. The reviewer may be offended and reviewers are people one does not want to offend. In general, I disagree. This get a bit philosophical, but well. I think there are some occasions where it is important to explain complicated things in few, easy to understand sentences to laymen (even if that means loss of preciseness). That has to be done (and was done in the past) with the other examples you give (thermodynamics, Krebs cycle ect.) fairly often, especially when politics are involved (think LHC, stem cells, or, even the structure of the DNA). Even for very difficult topics this needs to be done. I think our (maybe most challenging) duty as researchers paid by tax money is also to explain our sometimes very complicated research to laymen in an easy understandable manner. Albeit it is of course not your duty to explain it to me on this list, if you are offended by my attitude. Isn't it the most normal thing to ask for an explanation when somebody doesn't understand something? I've learned that asking is a good way of learning new things. Sorry if that offended you. This is mind-bogglingly well expressed. I wish I could write like that. Congratulations. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Quantiles of weighted sample
On Wed, 8 Oct 2008, Giovanni Petris wrote: I am wondering if there is a function in R that returns quantiles of a weighted sample, i.e., a set of values, each coming with a different weight. The function quantile() does that only for the case when the weights are all equal. In other words, I am looking for a quantile function that applies to a discrete distribution specified by values and their probabilities. There are at least two weighted quantile functions in packages: Hmisc::weighted.quantile and survey::svyquantile -thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
On Wednesday 08 October 2008, Manuel Morales wrote: On Wed, 2008-10-08 at 09:49 -0700, Dylan Beaudette wrote: On Wednesday 08 October 2008, Manuel Morales wrote: Another option is bargraph.CI or lineplot.CI from the package sciplot. See http://mutualism.williams.edu/sciplot for examples. On Tue, 2008-10-07 at 23:31 -0500, Michael Just wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. I've looked at lattice and gplots2, but given my beginner status my efforts are not propelling me very far. Thank you kindly, Michael Just # Personally, this looks more informative to me: library(lattice) bwplot(len ~ supp | factor(dose), data=ToothGrowth, layout=c(3,1)) # and some people like this: require(Hmisc) bwplot(supp ~ len | factor(dose), data=ToothGrowth, layout=c(3,1), panel=panel.bpplot, datadensity=TRUE) I guess personal preference but I prefer a layout that has them overlapping - visual comparison is easier. E.g.: require(sciplot) lineplot.CI(response=len, x.factor=dose, group=supp, data = ToothGrowth) If detail of the distributions are needed, the graphs you suggest are certainly warranted! Indeed. Form must usually follow function. I see what you mean about having then on the same axis. Thanks! -- Dylan Beaudette Soil Resource Laboratory http://casoilresource.lawr.ucdavis.edu/ University of California at Davis 530.754.7341 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Ecological Niche Modelling on R
On Wed, Oct 8, 2008 at 6:17 AM, milton ruser [EMAIL PROTECTED] wrote: [snip] Finally, in fact GRASP do what I am looking for, and I am starting to compare the results of this packages with other very wel- know softwares (DescktopGarp, Maxent, OpenModeller). If someone of you have suggestions of other R-solutions for Ecological Niche Models, please, let-me know. If you're interested in prediction methods based on presence-only data, you might find Gillian Ward's dissertation interesting ( http://www-stat.stanford.edu/~hastie/students.htm ). It includes reference to an accompanying R package (although it does not appear to be on CRAN). hth, Kingsford Jones Regards a lot. Savava. Miltinho Astronauta Brazil On Wed, Oct 8, 2008 at 6:02 AM, Clément Calenge [EMAIL PROTECTED] wrote: It's very kind of Stephen to plug my book, but it's notwhat you're looking for. You need to read more about this general topic, and aboutthe particular packages: try http://www.unine.ch/CSCF/grasp/grasp-r/index.htmlhttp://www.unine.ch/CSCF/grasp/ Based on downloading grasp , it doesn't look as thoughit will handle presence-only data, though -- you may needto look further. It doesn't look like adehabitat is what you want.From Calenge, Clement. 2006. The package adehabitat for the R software: A toolfor the analysis of space and habitat use by animals. Ecological Modelling 197,no. 3-4 (August 25): 516-519. doi:10.1016/j.ecolmodel.2006.03.017. ' ... the adehabitat package for the R software, which offers basic GIS(Geographic Information System) functions, methods to analyze radio-trackingdata and habitat selection by wildlife, and interfaces with other R packages.' General advice about I want to do X in R -- (expandingon Stephen's advice above): 1. read about X in general (perhaps you have already done this);2. search for R packages and functions that do what you want (you've already done this, although you misidentified adehabitat3. install those packages and see what they do. Look at thedocumentation included with the packages, including any citationsreferenced. Try the examples.4. If you don't know enough R to understand the examples or howto get your data into R, back up and read the introductory Rdocumentation. Actually, the confusion could be explained by the fact that many analyses methods (and especially factor analyses) originally developed in community ecology and biogeography to study the niche are also used in habitat selection studies (e.g., OMI analysis, ENFA, etc.). As the statistical issues (predict the species/animal presence on an area, given the value of environmental variables) and type of data (presence-only data to be compared with a sample/census of available units, etc.) involved in studies of the niche and habitat selection are often similar, the methods used are often similar too... However, most of the functions in adehabitat implement /exploratory/ methods of the ecological niche, and methods suitable for prediction are rare in the package (except one or two functions which have already been used for that, such as mahasuhab or domain, but they are probably not the best choice given your aim)... The package grasp may indeed be a better choice if your aim is prediction... But I concur with Ben and Stephen on the fact that you should first read the (large) literature on niche modelling before choosing the method that seems appropriate to your data/issue, and then search R archives/package for a solution. a good start: @ARTICLE{Elith2006, author = {Elith, J. and Graham, C.H. and Anderson, R.P. and Dudik, M. and Ferrier, S. and Guisan, A. and Hijmans, R.J. and Huettmann, F. and Leathwick, J.R. and Lehmann, A. and Li, J. and Lohmann, L.G. and Loiselle, B.A. and Manion, G. and Moritz, C. and Nakamura, M. and Nakazawa, Y. and McC. Overton, J. and Peterson, A.T. and Phillips, S.J. and Richardson, K. and Scachetti-Pereira, R. and Schapire, R.E. and Soberon, J. and Williams, S. and Wisz, M.S. and Zimmermann, N.E.}, title = {Novel methods improve prediction of species distributions from occurrence data}, journal = {Ecography}, year = {2006}, volume = {29}, pages = {129-151} } and references therein. Cheers, Clément Calenge. -- Clément CALENGE Office national de la chasse et de la faune sauvage Saint Benoist - 78610 Auffargis tel. (33) 01.30.46.54.14 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented,
Re: [R] par(new = TRUE) - overplotting
Hi Dieter, thanks a lot for looking inside my code though it was not executable...(sorry for that). Finally, I found a rather stupid mistake. My original code did not use the variable i for the second boxplot. So the second round actually plotted two different data at the two calls... so it had nothing to do with the par(new...) here some executable bug-free code :-) mydata - list(rnorm(100, mean=0.5, sd=0.1), rnorm(100, mean=0.7, sd=0.15)) lapply(c(1,2), FUN=function(i) { windows(7,7) use_col - c(blue) gridlines - seq(0.1,2.0,0.1) par(mar=c(12, 4, 5, 2)) bpars - list(yaxt = n, las = 2 ) boxplot(data.frame(mydata[[i]]), col=use_col, pars= bpars ) abline(h = gridlines, col=lightgray, lty=2) abline(h = 1, col=red, lwd=3) par(new=TRUE) boxplot(data.frame(mydata[i]), col=use_col, pars= bpars) }) ciao, Antje Dieter Menne schrieb: Antje niederlein-rstat at yahoo.de writes: I want to create some boxplots (as png) within an lapply method. To get nice gridlines behind the boxplot, I plotted it twice and therefore I set par(new=TRUE). This works nicely for the first plot but the second does plot on the first plot too and creates a mess... How can I force to start with a blank plot again??? lapply(c(1,2), FUN=function(i) { png(filename = test.png, width = 450, height = 600) gridlines - seq(0.1,2.0,0.1) par(mar=c(12, 4, 5, 2)) bpars - list(yaxt = n, las = 2 ) boxplot(mydata[i], pars= bpars ) abline(h = gridlines, col=lightgray, lty=2) abline(h = 1, col=red, lwd=3) par(new=TRUE) boxplot(mydata[i], pars= bpars, main = title) dev.off() }) I do not fully understand what you want to do, but in each case you overwrite your files. Try something like: png(filename = paste(test,i,.png), width = 450, height = 600) and think over again why you need the par(new=TRUE). And please, make your examples self-running, for example by adding mydata = rnorm(100) even if you probably have more complex data. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Strange horns on notched box plots
Hi I'm getting a weird result when I try to switch from a normal box plot to a notched one. The ends of the box fold down toward the median giving a horned appearance. Is just the sample itself? It is small, but the un-notched plot looks okay. Anyway to fix this? e7=as.vector(c(234,37,98,116,47)) boxplot(e7, plot=TRUE, notch=TRUE) Thanks very much. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Thank you very much for all your possible solutions!
I also managed to get the right result but within a for loop ;) So I really appreciate your solutions! Thanks a lot! -- View this message in context: http://www.nabble.com/Using-grep-tp19881017p19882769.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Re move repeated values
Dear R users, I'd like to make this data rem.y = c(-1,0,2,4,5) from y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5). That is, I need to remove repeated values. Here is my code, but I don't think it is efficient. How could I improve this? # y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5) n=length(y) for (i in 1:n) # removed same values in y { imsi = 0 if (i==1) {rem.y = y[i]} else {c = length(rem.y) for (j in 1:c) { if (y[i]==rem.y[j]) imsi=1 } if (imsi==0) rem.y = c(rem.y,y[i])} } rem.y #- Any suggestion will be greatly appreciated. Regards, Kathryn Lord -- View this message in context: http://www.nabble.com/Remove-repeated-values-tp19885503p19885503.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] detect repeated number in a vector
Dear R users, I have this vector that consists numeric numbers. Is there a command that detects the repeated numbers in a vector and returns the index of the repeated numbers (or the actual numbers)? For example, v - c(3,4,5,7,4). The command would return me index 2 and 5 (or the repeated number, 4). Thank you very much, Julia -- View this message in context: http://www.nabble.com/detect-repeated-number-in-a-vector-tp19884768p19884768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
On Wed, 2008-10-08 at 12:01 -0500, Michael Just wrote: Thank you all for you suggestions. They are all helpful. However, I have come to a more fundamental problem. Preparing my data to even make such a graph. I thought I was ready. I will obviously need to find the n, mean, and confidence interval for my data before I can plot them. for some of these plots. I thought perhaps this data manipulation would be easily done in R, but perhaps I should do it elsewhere and then bring it into R. I have about 5000 rows about 30 columns in my csv. I need to find: mean, n, confidence interval for a to-be-made selection from the entire data set. I have tried: aggregate, subset, dat$col1=2, etc Clearer?: I want to select data from my dataset where column1=2. Then when plotting this data I want to group it by 2 values (out of 4) from column10. Actually, the functions in sciplot will do this for you. All you need is to specify a response column, the column indicating the x-axis, the dataframe, and the subset of interest. E.g.: bargraph.CI(response=whatever.column.has.the.response, x.factor=col10, data=data, subset=col2==2) The default is to plot the mean +/- 1SE but this can be changed as needed. HTH, Manuel I know this is probably as clear as mud, thanks for you continuing patience. I would really appreciate any assistance you are able to provide me. My limited knowledge in R grows quite rapdily and things become so much more successful for me when I am granted tips and snippets of code form R users like you. Sincerely, Michael Just On Wed, Oct 8, 2008 at 11:25 AM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, Oct 7, 2008 at 11:31 PM, Michael Just [EMAIL PROTECTED] wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. Here's an alternative suggestion - don't use bars, use dots. Bar plots with standard errors are sometime called dynamite plots (probably because they should be blown up). See http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/DynamitePlots and http://emdbolker.wikidot.com/blog:dynamite for some reasons not to use them and possible alternatives. I hope that package authors who provide methods to make these plots easy will reconsider. Hadley -- http://had.co.nz/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://mutualism.williams.edu signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
On Wed, 2008-10-08 at 09:49 -0700, Dylan Beaudette wrote: On Wednesday 08 October 2008, Manuel Morales wrote: Another option is bargraph.CI or lineplot.CI from the package sciplot. See http://mutualism.williams.edu/sciplot for examples. On Tue, 2008-10-07 at 23:31 -0500, Michael Just wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. I've looked at lattice and gplots2, but given my beginner status my efforts are not propelling me very far. Thank you kindly, Michael Just # Personally, this looks more informative to me: library(lattice) bwplot(len ~ supp | factor(dose), data=ToothGrowth, layout=c(3,1)) # and some people like this: require(Hmisc) bwplot(supp ~ len | factor(dose), data=ToothGrowth, layout=c(3,1), panel=panel.bpplot, datadensity=TRUE) I guess personal preference but I prefer a layout that has them overlapping - visual comparison is easier. E.g.: require(sciplot) lineplot.CI(response=len, x.factor=dose, group=supp, data = ToothGrowth) If detail of the distributions are needed, the graphs you suggest are certainly warranted! -- http://mutualism.williams.edu signature.asc Description: This is a digitally signed message part __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plot means with error bars - A novice needs help
Manuel, Thanks, this worked well. I was also toying around with other options in bargraph.CI per your suggestion. Thanks, Michael bargraph.CI(RecovUnit, bbED, group = year, data =scape234, + xlab = Recovery Unit, ylab = Edge Density, cex.lab = 1.5, x.leg = 1, + density = c(0,20), legend = TRUE) On Wed, Oct 8, 2008 at 2:28 PM, Manuel Morales [EMAIL PROTECTED] wrote: On Wed, 2008-10-08 at 12:01 -0500, Michael Just wrote: Thank you all for you suggestions. They are all helpful. However, I have come to a more fundamental problem. Preparing my data to even make such a graph. I thought I was ready. I will obviously need to find the n, mean, and confidence interval for my data before I can plot them. for some of these plots. I thought perhaps this data manipulation would be easily done in R, but perhaps I should do it elsewhere and then bring it into R. I have about 5000 rows about 30 columns in my csv. I need to find: mean, n, confidence interval for a to-be-made selection from the entire data set. I have tried: aggregate, subset, dat$col1=2, etc Clearer?: I want to select data from my dataset where column1=2. Then when plotting this data I want to group it by 2 values (out of 4) from column10. Actually, the functions in sciplot will do this for you. All you need is to specify a response column, the column indicating the x-axis, the dataframe, and the subset of interest. E.g.: bargraph.CI(response=whatever.column.has.the.response, x.factor=col10, data=data, subset=col2==2) The default is to plot the mean +/- 1SE but this can be changed as needed. HTH, Manuel I know this is probably as clear as mud, thanks for you continuing patience. I would really appreciate any assistance you are able to provide me. My limited knowledge in R grows quite rapdily and things become so much more successful for me when I am granted tips and snippets of code form R users like you. Sincerely, Michael Just On Wed, Oct 8, 2008 at 11:25 AM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, Oct 7, 2008 at 11:31 PM, Michael Just [EMAIL PROTECTED] wrote: Hello, I'd appreciate a suggestion on how to construct plots (barplots?) that use means on the Y axis instead of density/count. I'd also like to use groups and plot error or confidence interval bars on these graphs. I know this is a read the manual situation. I'd appreciate help with what to read, or your benevolence with some sample code. Here's an alternative suggestion - don't use bars, use dots. Bar plots with standard errors are sometime called dynamite plots (probably because they should be blown up). See http://biostat.mc.vanderbilt.edu/twiki/bin/view/Main/DynamitePlots and http://emdbolker.wikidot.com/blog:dynamite for some reasons not to use them and possible alternatives. I hope that package authors who provide methods to make these plots easy will reconsider. Hadley -- http://had.co.nz/ [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://mutualism.williams.edu [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re move repeated values
Kathryn ?unique and see also duplicated. unique(c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5)) [1] -1 0 2 4 5 HTH Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of kathie Sent: Thursday, 9 October 2008 8:12 a.m. To: r-help@r-project.org Subject: [R] Re move repeated values Dear R users, I'd like to make this data rem.y = c(-1,0,2,4,5) from y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5). That is, I need to remove repeated values. Here is my code, but I don't think it is efficient. How could I improve this? #- --- y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5) n=length(y) for (i in 1:n) # removed same values in y { imsi = 0 if (i==1) {rem.y = y[i]} else {c = length(rem.y) for (j in 1:c) { if (y[i]==rem.y[j]) imsi=1 } if (imsi==0) rem.y = c(rem.y,y[i])} } rem.y #- Any suggestion will be greatly appreciated. Regards, Kathryn Lord -- View this message in context: http://www.nabble.com/Remove-repeated-values-tp19885503p19885503.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. The contents of this e-mail are privileged and/or confidential to the named recipient and are not to be used by any other person and/or organisation. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] detect repeated number in a vector
On 08/10/2008 2:36 PM, liujb wrote: Dear R users, I have this vector that consists numeric numbers. Is there a command that detects the repeated numbers in a vector and returns the index of the repeated numbers (or the actual numbers)? For example, v - c(3,4,5,7,4). The command would return me index 2 and 5 (or the repeated number, 4). duplicated() comes close, but the first occurence doesn't count as a duplication: duplicated(v) [1] FALSE FALSE FALSE FALSE TRUE To convert into values, you can index v by it: v[duplicated(v)] [1] 4 and to find which indices are duplicated, indices - seq_along(v) indices[duplicated(v)] [1] 5 If you really want to include the the first one, you can do something like: indices[ v %in% v[duplicated(v)] ] [1] 2 5 Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Announcing R-PLUS 3.3 Experience-Rplus
Interactive, Comprehensive and Highly Visual ! R-PLUS 3.3 Rocks :) At a click, import data from different formats, use Excel-like spreadsheet for manipulating your data, create publication-quality reports, generate editable graphics ... and click click to run your favorite models through dialogs. Check out the screenshots at www.Experience-Rplus.com and tell us what you think. Register for free trial. Regards - Sue www.Experience-Rplus.com Ps. USAR2009 is an R|R-PLUS conference scheduled in Las Vegas - April 26-30, 2009 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re move repeated values
Dear Kathie, See ?unique. y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5) unique(y) [1] -1 0 2 4 5 HTH, Jorge On Wed, Oct 8, 2008 at 3:12 PM, kathie [EMAIL PROTECTED] wrote: Dear R users, I'd like to make this data rem.y = c(-1,0,2,4,5) from y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5). That is, I need to remove repeated values. Here is my code, but I don't think it is efficient. How could I improve this? # y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5) n=length(y) for (i in 1:n) # removed same values in y { imsi = 0 if (i==1) {rem.y = y[i]} else {c = length(rem.y) for (j in 1:c) { if (y[i]==rem.y[j]) imsi=1 } if (imsi==0) rem.y = c(rem.y,y[i])} } rem.y #- Any suggestion will be greatly appreciated. Regards, Kathryn Lord -- View this message in context: http://www.nabble.com/Remove-repeated-values-tp19885503p19885503.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Re move repeated values
kathie wrote: Dear R users, I'd like to make this data rem.y = c(-1,0,2,4,5) from y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5). That is, I need to remove repeated values. Here is my code, but I don't think it is efficient. How could I improve this? By using the 'unique' function, as in, rem.y - unique(y). Almost any time you use subscripts, you should ask yourself if there's a vectorized function already available. # y = c(-1,-1,0,2,2,2,2,4,4,5,5,5,5,5) n=length(y) for (i in 1:n) # removed same values in y { imsi = 0 if (i==1) {rem.y = y[i]} else {c = length(rem.y) for (j in 1:c) { if (y[i]==rem.y[j]) imsi=1 } if (imsi==0) rem.y = c(rem.y,y[i])} } rem.y #- Any suggestion will be greatly appreciated. Regards, Kathryn Lord __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Choose subset for plot use (bwplot)
Hello, this code below was from a helpful R-help user. dat - read.csv(Resid_fix2.csv, sep=, , header=T) dat11 - dat[1:413,] # convert ambiguous columns to factors: dat11$Pri_No - factor(dat11$Pri_No) dat11$RecovUnit - factor(dat11$RecovUnit) # plot: require(lattice) bwplot(bbED~ Pri_No | RecovUnit, data=dat11, as.table=TRUE, layout=c(4,1)) This works, but I am trying to do this: bwplot(bbED~ Pri_No | RecovUnit, data=dat11, subset = (Pri_No %in% c(1,2)), as.table=TRUE, layout=c(2,1)) Error in limits.and.aspect(prepanel.default.bwplot, prepanel = prepanel, : need at least one panel How can I choose only two groups from 'Pri_No'? Thank you kindly, Michael Just [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] detect repeated number in a vector
Can this be an answer ? which(v %in% names(table(v)[table(v)1])) [1] 2 5 Nael On Wed, Oct 8, 2008 at 8:36 PM, liujb [EMAIL PROTECTED] wrote: Dear R users, I have this vector that consists numeric numbers. Is there a command that detects the repeated numbers in a vector and returns the index of the repeated numbers (or the actual numbers)? For example, v - c(3,4,5,7,4). The command would return me index 2 and 5 (or the repeated number, 4). Thank you very much, Julia -- View this message in context: http://www.nabble.com/detect-repeated-number-in-a-vector-tp19884768p19884768.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to join the two tables based on one overlapped column
Dear Daniel, Thank you very much for the help! I tried the code and got the following: John-read.table(file=John_probe.txt,header=TRUE,row.names=NULL,fill=TRUE) Susan-read.table(file=Susan_probe.txt,header=TRUE,row.names=NULL,fill=TRUE) dim(John) [1] 48701 2 dim(Susan) [1] 46713 2 dataToMerge=data.frame(John$PROBE_ID2, John$SEARCH_KEY2) mergedData=merge(Susan,dataToMerge,by.x=SEARCH_KEY1,by.y=SEARCH_KEY2,all.x=T,all.y=F) Error in fix.by(by.x, x) : object SEARCH_KEY1 not found I modified the last one by specifying the file name and got : mergedData=merge(Susan,dataToMerge,by.x=Susan$SEARCH_KEY1,by.y=John$SEARCH_KEY2,all.x=T,all.y=F) Error in fix.by(by.x, x) : 'by' must specify valid column(s) Have you got any clue about this? Thanks much, Allen On Wed, Oct 8, 2008 at 11:46 AM, Daniel Malter [EMAIL PROTECTED] wrote: dataToMerge=data.frame(yourtablename2$PROBE_ID2, yourtablename2$SEARCH_KEY2) ##Puts the two columns of interest in dataset 2 in a separate data frame. mergedData=merge(yourtablename1,dataToMerge,by.x=SEARCH_KEY1,by.y=SEARCH_KEY 2,all.x=T,all.y=F) ##merges the first table with the data frame just created looking for matches between SEARCH_KEY1 and SEARCH_KEY2, all entries in dataset 1 are retained (whether matched or not), entries in the dataToMerge dataframe that do not match any entries in dataset 1 are dropped. You then have an additional column in mergedData that contains the PROBE_ID2 and you can just assign them to PROBE_ID1 (i.e. replace PROBE_ID1 by the values in this column). Cheers, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im Auftrag von ss Gesendet: Wednesday, October 08, 2008 11:33 AM An: R help Betreff: [R] How to join the two tables based on one overlapped column Dear list, I need some clues on this. I have two excel files and I basically want to map one to the other one. Can you give me some hints how to do it? The first excel file, named as Susan_probe.xls, there are two columns, PROBE_ID1 and SEARCH_KEY1 PROBE_ID1 SEARCH_KEY1 ILMN_30212 ILMN_30212 ILMN_1285 ILMN_1285 ILMN_137964 ILMN_137964 ILMN_138109 ILMN_138109 ... The second excel file, named as John_probe.xls, there are two columns as well, PROBE_ID2 and SEARCH_KEY2. PROBE_ID2 SEARCH_KEY2 ILMN_1809034 ILMN_16367 ILMN_1660305 ILMN_16583 ILMN_1792173 ILMN_19158 ... There are 46713 rows in the first excel file and 49702 rows in the second file. Probes in the first columns of two excel files are different but they can be matched based on the second column SEARCH_KEY. So what I want to do is to substitute the PROBE_ID1 in the Susan_probe.xls file with the PROBE_ID2 in the John_probe.xls based on their common SEARCH_KEY. Thank you so much for your help. I really appreciate. All the best, Allen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] error installing lattice package
I just updated my Redhat EL systems to R-2.7.2, and tried to update my packages as well. Lattice is one that failed. What do I need to do? R version 2.7.2 (2008-08-25) install.packages(lattice, repos = http://cran.fhcrc.org/;) Warning in install.packages(lattice, repos = http://cran.fhcrc.org/;) : argument 'lib' is missing: using '/usr/lib/R/library' trying URL 'http://cran.fhcrc.org/src/contrib/lattice_0.17-15.tar.gz' Content type 'application/x-gzip' length 281977 bytes (275 Kb) opened URL == downloaded 275 Kb * Installing *source* package 'lattice' ... ** libs gcc -I/usr/include/R -I/usr/local/include-fpic -O2 -g -std=gnu99 -c init.c -o init.o init.c:2:15: R.h: No such file or directory init.c:3:24: Rinternals.h: No such file or directory init.c:4:28: R_ext/Rdynload.h: No such file or directory In file included from init.c:6: threeDplot.h:5:22: Rdefines.h: No such file or directory In file included from init.c:6: threeDplot.h:9: error: syntax error before wireframePanelCalculations threeDplot.h:9: error: syntax error before xArg threeDplot.h:15: warning: type defaults to `int' in declaration of `wireframePanelCalculations' threeDplot.h:15: warning: data definition has no type or storage class init.c:8: error: syntax error before CallEntries init.c:8: warning: type defaults to `int' in declaration of `CallEntries' init.c:9: warning: braces around scalar initializer init.c:9: warning: (near initialization for `CallEntries[0]') init.c:9: warning: initialization makes integer from pointer without a cast init.c:9: error: `DL_FUNC' undeclared here (not in a function) init.c:9: warning: excess elements in scalar initializer init.c:9: warning: (near initialization for `CallEntries[0]') init.c:9: warning: excess elements in scalar initializer init.c:9: warning: (near initialization for `CallEntries[0]') init.c:10: warning: braces around scalar initializer init.c:10: warning: (near initialization for `CallEntries[1]') init.c:10: error: `NULL' undeclared here (not in a function) init.c:10: error: initializer element is not constant init.c:10: error: (near initialization for `CallEntries[1]') init.c:10: warning: excess elements in scalar initializer init.c:10: warning: (near initialization for `CallEntries[1]') init.c:10: warning: excess elements in scalar initializer init.c:10: warning: (near initialization for `CallEntries[1]') init.c:10: error: initializer element is not constant init.c:10: error: (near initialization for `CallEntries[1]') init.c:11: warning: data definition has no type or storage class init.c:13: error: syntax error before '*' token init.c: In function `R_init_lattice': init.c:15: warning: implicit declaration of function `R_registerRoutines' init.c:15: error: `dll' undeclared (first use in this function) init.c:15: error: (Each undeclared identifier is reported only once init.c:15: error: for each function it appears in.) init.c:16: warning: implicit declaration of function `R_useDynamicSymbols' init.c:16: error: `FALSE' undeclared (first use in this function) make: *** [init.o] Error 1 ERROR: compilation failed for package 'lattice' ** Removing '/usr/lib/R/library/lattice' ** Restoring previous '/usr/lib/R/library/lattice' Thanks, Scott Waichler Pacific Northwest National Laboratory [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] trouble with character \u00e2
On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you Professor: Here is an example using R2.8.0 beta. It shows the coding to be latin1 But you did not use file.choose or basename here. I installed my package which requires rcom, RODBC, RColorBrewer, survival I was unable to find rcom in the packages drop-down menu. I tried mirrors USA(PA) and USA(PA2). rcom does appear in the menu run under R2.7.2, however. __ R version 2.8.0 beta (2008-10-07 r46631) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. ls() character(0) file.label - EXAMPLE 1 â vs a.xls charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 e2 20 76 73 20 61 2e 78 6c 73 Encoding(file.label) [1] latin1 Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 2:20 PM To: Charles Annis, P.E. Subject: RE: [R] trouble with character \u00e2 On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Professor Ripley: Can I get the Windows binaries for R2.8.0 beta? I looked earlier today and found the tar files but not any binaries. http://cran.r-project.org/src/base-prerelease/ http://cran.r-project.org/bin/windows/base/rtest.html or look via Windows. Thank you. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 1:10 PM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: RE: [R] trouble with character \u00e2 Can you please try a 2.8.0 beta build? I have a suspicion as to what might be going on, and it cannot happen there. If my guess is correct, nfile - paste(diagnostic â vs a , file.label, .jpg, sep = ) savePlot(path.expand(nfile), type=jpg) may work for you in 2.7.2 (but as I said, I wasn't able to reproduce this there). The crucial bit is to use path.expand() on the final file name: it will do nothing except ensure that the encoding is correct. On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you Professor: After reading in the file this is what I see: file.label [1] EXAMPLE 1 â vs a.xls charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 Encoding(file.label) [1] UTF-8 Encoding(paste(diagnostic â vs a , file.label, .jpg, sep = )) [1] UTF-8 But look what happens after I run your example: charToRaw(file.label) [1] 45 58 41 4d 50 4c 45 20 31 20 e2 20 76 73 20 61 2e 78 6c 73 (after) [1] 45 58 41 4d 50 4c 45 20 31 20 c3 a2 20 76 73 20 61 2e 78 6c 73 (before) The file label appears on the screen as it does above both times, but clearly charToRaw() shows that the coding for â has changed from the unexpected c3 a2, to the desired e2. After running your example I now observe Encoding(file.label) [1] latin1 Again, thank you for your help. Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 08, 2008 10:32 AM To: Charles Annis, P.E. Cc: r-help@r-project.org Subject: RE: [R] trouble with character \u00e2 That also works without a hitch on my box, even in vanilla 2.7.2. What exactly is in file.label as given by charToRaw(file.label) Encoding(file.label) ? It should be in UTF-8, and so should paste(diagnostic â vs a , file.label, .jpg, sep = ) It looks like the latter is not being treated as UTF-8 on your system (see what Encoding() says on its value). On Wed, 8 Oct 2008, Charles Annis, P.E. wrote: Thank you, Professor Ripley: Your example works for me too. plot(1:10, xlab = a, ylab = â) file.label - EXAMPLE 1 â vs a.xls savePlot(paste(diagnostic â vs a , file.label, .jpg, sep = ), type = jpg) But, if I read-in the file name using file.choose() I get the same corrupted output filename ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ) from my R routines. However, if I paste that same file.label as it is printed to the screen with my input routine, replacing your foo (as above) things work as they should ( diagnostic â vs a EXAMPLE 1 â vs a.xls.jpg ). Furthermore, if I again run my plotting routines
Re: [R] ParallelR
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Chi, ParallelR is a commercial software to run R in parallel. It is working very well. We tested it at a small linux cluster. You also can use R and the parallel packages (snow, Rmpi, nws, ...) packages. All Open Source and for free. You probably will have some more work installing the complete system, but the same results. You also can use a batch system with R. We are using Sun Grid Engine! (this should be even possible for parallelR) Best Markus Chi Chan wrote: Anyone using or has access to ParallelR? I was looking at the page and found nothing really useful! http://www.revolution-computing.com/sitegenius/topic.php?id=195 I want to see if I can run R on a cluster of workstation, and use batch systems like Grid Engine or Xgrid: http://gridengine.sunsource.net/ http://ww.apple.com/acg/xgrid/ --Chi __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.4-svn0 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iD8DBQFI7SGUwxqyUctZsggRAjInAJ9Cw7cy97nVa57lokaWFx7VJk2iwwCeOuwO KHcLP7HUUMSmfak+oLrQjXU= =fPMX -END PGP SIGNATURE- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] error installing lattice package
On Wed, 8 Oct 2008, Waichler, Scott R wrote: I just updated my Redhat EL systems to R-2.7.2, and tried to update my packages as well. Lattice is one that failed. What do I need to do? Install the R-devel RPM? (Assuming you installed R from an RPM.) R version 2.7.2 (2008-08-25) install.packages(lattice, repos = http://cran.fhcrc.org/;) Warning in install.packages(lattice, repos = http://cran.fhcrc.org/;) : argument 'lib' is missing: using '/usr/lib/R/library' trying URL 'http://cran.fhcrc.org/src/contrib/lattice_0.17-15.tar.gz' Content type 'application/x-gzip' length 281977 bytes (275 Kb) opened URL == downloaded 275 Kb * Installing *source* package 'lattice' ... ** libs gcc -I/usr/include/R -I/usr/local/include-fpic -O2 -g -std=gnu99 -c init.c -o init.o init.c:2:15: R.h: No such file or directory init.c:3:24: Rinternals.h: No such file or directory init.c:4:28: R_ext/Rdynload.h: No such file or directory In file included from init.c:6: threeDplot.h:5:22: Rdefines.h: No such file or directory In file included from init.c:6: threeDplot.h:9: error: syntax error before wireframePanelCalculations threeDplot.h:9: error: syntax error before xArg threeDplot.h:15: warning: type defaults to `int' in declaration of `wireframePanelCalculations' threeDplot.h:15: warning: data definition has no type or storage class init.c:8: error: syntax error before CallEntries init.c:8: warning: type defaults to `int' in declaration of `CallEntries' init.c:9: warning: braces around scalar initializer init.c:9: warning: (near initialization for `CallEntries[0]') init.c:9: warning: initialization makes integer from pointer without a cast init.c:9: error: `DL_FUNC' undeclared here (not in a function) init.c:9: warning: excess elements in scalar initializer init.c:9: warning: (near initialization for `CallEntries[0]') init.c:9: warning: excess elements in scalar initializer init.c:9: warning: (near initialization for `CallEntries[0]') init.c:10: warning: braces around scalar initializer init.c:10: warning: (near initialization for `CallEntries[1]') init.c:10: error: `NULL' undeclared here (not in a function) init.c:10: error: initializer element is not constant init.c:10: error: (near initialization for `CallEntries[1]') init.c:10: warning: excess elements in scalar initializer init.c:10: warning: (near initialization for `CallEntries[1]') init.c:10: warning: excess elements in scalar initializer init.c:10: warning: (near initialization for `CallEntries[1]') init.c:10: error: initializer element is not constant init.c:10: error: (near initialization for `CallEntries[1]') init.c:11: warning: data definition has no type or storage class init.c:13: error: syntax error before '*' token init.c: In function `R_init_lattice': init.c:15: warning: implicit declaration of function `R_registerRoutines' init.c:15: error: `dll' undeclared (first use in this function) init.c:15: error: (Each undeclared identifier is reported only once init.c:15: error: for each function it appears in.) init.c:16: warning: implicit declaration of function `R_useDynamicSymbols' init.c:16: error: `FALSE' undeclared (first use in this function) make: *** [init.o] Error 1 ERROR: compilation failed for package 'lattice' ** Removing '/usr/lib/R/library/lattice' ** Restoring previous '/usr/lib/R/library/lattice' Thanks, Scott Waichler Pacific Northwest National Laboratory [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.