Re: [R] installing R on Ubuntu
On Sun, 8 Feb 2009, Tom Backer Johnsen wrote: Dirk Eddelbuettel wrote: On 8 February 2009 at 20:36, Tom Backer Johnsen wrote: | Dear me. Is the installation of R under Ubuntu really that complex? I | have a dual boot machine (Linux / Windows, where I use the latter the | most) and have plans to try R under Linux, but have not done so yet. Is | it possible to simplify the Linux install procedure to make R more | accessible to novices? Yes. 'sudo apt-get install r-base ess ggobi' and you have working R, ESS and Ggobi. Start Emacs, type 'M-x R' and you have an R session inside Emacs. Is that really easier to accomplish in Windows? No. If it is that simple to install R under a Debian vaiant of Linux, it definitely is easier. On the other hand, using Emacs is not (as far as I know) the thing for novices. What I would prefer is something that is as simple to use as the Windows (or even better, the Mac interface) for R. You might like JGR, then. http://jgr.markushelbig.org/JGR.html -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ 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] uniroot() problem
Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656 # time to maturity in year ii = 2.309/100 # interest rate, annualized th.price = function(x) { d1 = (log(uu/K) + (ii + x^2/2)*tt) / (x*sqrt(tt)); d2 = d1 - x*sqrt(tt) option.price = uu * pnorm(d1) - K * exp(-ii*tt) * pnorm(d2) return(option.price - oo) } uniroot(th.price, c(-20, 20), tol=1/10^12) I got following result : uniroot(th.price, c(-20, 20), tol=1/10^12) $root [1] 6.331672e-13 $f.root [1] 36.28816 $iter [1] 55 $estim.prec [1] 7.385592e-13 Hence using implied volatility, difference between traded price and theoretical price is coming as high as 36.28816, even I increse the precision level. Any idea how to crack this problem? Albyn Jones wrote: One can't tell for sure without seeing the function, but I'd guess that you have a numerical issue. Here is an example to reflect upon: f=function(x) (exp(x)-exp(50))*(exp(x)+exp(50)) uniroot(f,c(0,100)) $root [1] 49.7 $f.root [1] -1.640646e+39 $iter [1] 4 $estim.prec [1] 6.103516e-05 .Machine$double.eps^0.25/2 [1] 6.103516e-05 uniroot thinks it has converged, at least in relative terms. Note that the estimated precision is related to the machine epsilon, used in the default value for tol. try fiddling with the tol argument. uniroot(f,c(0,100),tol=1/10^12) $root [1] 50 $f.root [1] 1.337393e+31 $iter [1] 4 $estim.prec [1] 5.186962e-13 albyn Quoting megh megh700...@yahoo.com: I have a strange problem with uniroot() function. Here is the result : uniroot(th, c(-20, 20)) $root [1] 4.216521e-05 $f.root [1] 16.66423 $iter [1] 27 $estim.prec [1] 6.103516e-05 Pls forgive for not reproducing whole code, here my question is how f.root can be 16.66423? As it is finding root of a function, it must be near Zero. Am I missing something? -- View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21227702.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. -- View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21909423.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] uniroot() problem
Sorry, in my previous post I forgot to include strike price, which is K = 1160 megh wrote: Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656 # time to maturity in year ii = 2.309/100 # interest rate, annualized th.price = function(x) { d1 = (log(uu/K) + (ii + x^2/2)*tt) / (x*sqrt(tt)); d2 = d1 - x*sqrt(tt) option.price = uu * pnorm(d1) - K * exp(-ii*tt) * pnorm(d2) return(option.price - oo) } uniroot(th.price, c(-20, 20), tol=1/10^12) I got following result : uniroot(th.price, c(-20, 20), tol=1/10^12) $root [1] 6.331672e-13 $f.root [1] 36.28816 $iter [1] 55 $estim.prec [1] 7.385592e-13 Hence using implied volatility, difference between traded price and theoretical price is coming as high as 36.28816, even I increse the precision level. Any idea how to crack this problem? Albyn Jones wrote: One can't tell for sure without seeing the function, but I'd guess that you have a numerical issue. Here is an example to reflect upon: f=function(x) (exp(x)-exp(50))*(exp(x)+exp(50)) uniroot(f,c(0,100)) $root [1] 49.7 $f.root [1] -1.640646e+39 $iter [1] 4 $estim.prec [1] 6.103516e-05 .Machine$double.eps^0.25/2 [1] 6.103516e-05 uniroot thinks it has converged, at least in relative terms. Note that the estimated precision is related to the machine epsilon, used in the default value for tol. try fiddling with the tol argument. uniroot(f,c(0,100),tol=1/10^12) $root [1] 50 $f.root [1] 1.337393e+31 $iter [1] 4 $estim.prec [1] 5.186962e-13 albyn Quoting megh megh700...@yahoo.com: I have a strange problem with uniroot() function. Here is the result : uniroot(th, c(-20, 20)) $root [1] 4.216521e-05 $f.root [1] 16.66423 $iter [1] 27 $estim.prec [1] 6.103516e-05 Pls forgive for not reproducing whole code, here my question is how f.root can be 16.66423? As it is finding root of a function, it must be near Zero. Am I missing something? -- View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21227702.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. -- View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21909458.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] Abstract submission deadline for useR! 2009
Dear members of the R user community, the submission deadline for useR! 2009 (Rennes, France, July 8 to 10, 2009) is approaching: Submission deadline: 2009-02-27 (and along with that the early registration deadline). We encourage you to give a presentation at the conference and submit an abstract or a poster on topics presenting innovations or exciting applications of R. You can use the conference Web page at http://www.R-project.org/useR-2009/ Invited speakers will include: Adele Cutler, Peter Dalgaard, Jerome H. Friedman, Michael Greenacre, Trevor Hastie, John Storey, Martin Theus. July 7, 2009, half-day tutorials are presented by R experts prior to the conference. The conference web page: http://www.agrocampus-ouest.fr/math/useR-2009/accomodation.html gives a list of hotels and some student rooms (200) are also available on the campus (Rennes will be very busy at the conference time because the cultural event `Festival Les tombées de la nuit' will take place at the same time, so we recommend to book as soon as possible). We hope to meet you in Rennes! F. Husson for the organizing committee. ___ r-annou...@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ 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] Installing package RODBC error - please help
Hi, Anyone please help installing RODBC? Cumprimentos, Joao Vaz Product Engineer QPT Product Engineering Qimonda Portugal S.A. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vaz Joao (QPT TO EPA) Sent: Thursday, February 05, 2009 1:30 PM To: r-help@r-project.org Subject: [R] Installing package RODBC error - please help Hi, I have R version 2.8.1 running on Windows 2000 and can't seem to be able to install package RODBC. I've tried reinstalling R but that wasn't successful. Can some one please help? This is the command I'm using and the subsequent error message: install.packages(RODBC, .Library, repos=http://cran.r-project.org;, method=internal, destdir=getwd()) Warning: unable to access index for repository http://cran.r-project.org/bin/windows/contrib/2.8 Warning message: package 'RODBC' is not available Thanks, Joao Vaz __ 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] Installing package RODBC error - please help
Try using a mirror instead of cran.r-project.org. HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Vaz Joao (QPT TO EPA) Verzonden: maandag 9 februari 2009 10:49 Aan: r-help@r-project.org Onderwerp: Re: [R] Installing package RODBC error - please help Hi, Anyone please help installing RODBC? Cumprimentos, Joao Vaz Product Engineer QPT Product Engineering Qimonda Portugal S.A. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vaz Joao (QPT TO EPA) Sent: Thursday, February 05, 2009 1:30 PM To: r-help@r-project.org Subject: [R] Installing package RODBC error - please help Hi, I have R version 2.8.1 running on Windows 2000 and can't seem to be able to install package RODBC. I've tried reinstalling R but that wasn't successful. Can some one please help? This is the command I'm using and the subsequent error message: install.packages(RODBC, .Library, repos=http://cran.r-project.org;, method=internal, destdir=getwd()) Warning: unable to access index for repository http://cran.r-project.org/bin/windows/contrib/2.8 Warning message: package 'RODBC' is not available Thanks, Joao Vaz __ 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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] installing R on Ubuntu
On Sun, 2009-02-08 at 16:21 -0500, Jonathan Baron wrote: For those reading this thread who might be thinking of trying Linux, I would like to point out that, with Fedora (another distribution of Linux aside from Ubuntu), the repositories are up to date, and there seems to be someone connected with Fedora (as well as the R core team) who is interested in keeping them that way. [Others should stop reading now. This is just for those considering Fedora.] There are several ways to install programs in the form of rpms. (Originally stood for Red Hat Package Manager.) Perhaps the simplest is, as root: yum install R This gets you a lot of additional rpm's (dependencies) if you don't have them. Fedora also maintains rpm's of various R packages, a seemingly random selection of them, but you don't need to depend on Fedora for those. Once R is installed, you can invoke R as root and then say, for example, from the prompt: install.packages(lmer) Hi Jon, As much as I love Fedora (and I've used it from Core 1 onwards and haven't been swayed by Ubuntu's lovely brownness), I should point out that it need *not* be as simple as you make out on Fedora. Your install.packages(foo) invocation does require that you have installed all the build tools and development packages required to compile foo from source. Where foo does not depend upon external libraries being on your system (and their development headers), it is often as easy as you make out. Try building rgl with a simple Fedora installation however and you'll soon hit a brick wall. (I, being fairly impatient, just installed anything mesa or GLU -devel from the yum repo until I got rgl to compile, but I had to know to look as MESA or GLU or whatever it was...) As to the version of R in Fedora's package repository being up-to-date, I think this reflects more the nature of Fedora being a bleeding-edge distro, whereas Debian is much more focussed on stability. From time to time on this list, getting the latest version of R on Debian/Ubuntu comes up and Dirk or someone IIRC points out that the latest version has been packaged but just not in the stable package repository. The latest version is there, thanks to the efforts of these third parties, but you need to know where to grab it from. This is a difference in philosophy surrounding the different distributions, not an ease of use or more-up-to-datedness issue. This all boils down to knowing how to use your distro and knowing a bit about the packaging systems on Linux and your particular flavour of Linux. (Something Linux could do a lot better at...) IMHO, compiling from source on Fedora is easier than dealing with a mixture of rpm packages in Fedora's package repositories and having to compile from source those packages that aren't. If you can compile packages from source then you can (most likely) compile R itself, and then you can run it from wherever you want and you won't need to run it as root to install/update packages. And then you can be as bleeding edge as you like... My 4p worth (the pound isn't what it once was...) G If you want to install ess and xemacs, I think all you need to say is yum install xemacs-ess-el which will install, as dependencies, everything else you need, including xemacs if you don't have it. Although Ubuntu is recommended for Linux newbies, it may be the case that Fedora is a little easier, at least about this. Warning: Fedora is pure about open-source licenses, which means that many closed-source programs that you might want, like Adobe Flash, Skype, and some drivers, won't be there unless you get them yourself (and you can do that). Jon -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 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] (no subject)
Is there a general method for finding out what something is in R please. I have a list (bycontract) that; is.list(bycontract3) [1] TRUE And an element of this list would be this say; bycontract3[[1]] [1] 22 3.2 -8 -17 49 3 [7] 30 -3 -21 8 3 12 [13] 49 19 -13 -2 25 39 [19] -12 -90 -1 15 -87 30 I can not seem to see what type of object this element is (is.list = FALSE) - also is there a way to take all the elements and just put them in just one series please Regards glenn [[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] Problem in appending a row to *.csv file
Hi all, I am new to R-project I have a problem when when ever I am going to append a row in a *.csv file that is in R-project I created one dataframe and I saved it in res.csv and again I got some results in dataframe with same column names and i tried to append in a new row of same res.csv file but its appending again with columnnaes like first time when i created the csv file ,max,min,avg 1,22,7,12.98333 and when I try to append another column for this file its writing like ,max,min,avg 1,22,7,12.98333 ,max,min,avg 1,19,7,12.9918699186992 can any one suggest how to solve this problem and how can I save new rows without taking column names and also i tried withappend() function to append to dataframes then also its giving the same result thanks in advance [[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] paraPen in gam [mgcv 1.4-1.1] and centering constraints
Daniel, There's nothing built in to constraint the coefficients in this way, but it's not too difficult to reparameterize to impose any linear constraint. The key is to find an orthogonal basis for null space of the constraint. Then it's easy to re-parameterize to work in that space. Here's a simple linear model based example ## simulated problem: linear model subject to constraint ## i.e y = X b + e subject to C b=0 X - matrix(runif(40),10,4) ## a model matrix y - rnorm(10) ## a response C - matrix(1,1,4) ## a constraint matrix so C b = 0 ## Get a basis for null space of constraint... qrc - qr(t(C)) Z - qr.Q(qrc,complete=TRUE)[,(nrow(C)+1):ncol(C)] ## absorb constraint into basis... XZ - X%*%Z ## fit model b - lm(y~XZ-1) ## back to original parameterization beta - Z%*%coef(b) sum(beta) ## it works! ## If there had been a penalty matrix, S, as well, ## then it should have been transformed as follows S - t(Z)%*%S%*%Z ... So provided that you have the model matrix for the term that you want to penalize in `gam' then it's just a matter of transforming that model matrix and corresponding penalty/ies, using a null space matrix like Z. Note that the explicit formation of Z is not optimally efficient here, but this won't have a noticeable impact on the total computational cost in this context anyway (given that mgcv is not able to make use of all that lovely sparcity in the MRF, :-( ). Hope this helps. best, Simon On Saturday 07 February 2009 21:00, Daniel Sabanés Bové wrote: Dear Mr. Simon Wood, dear list members, I am trying to fit a similar model with gam from mgcv compared to what I did with BayesX, and have discovered the relatively new possibility of incorporating user-defined matrices for quadratic penalties on parametric terms using the paraPen argument. This was really a very good idea! However, I would like to constraint the coefficients belonging to one penalty matrix to sum to zero. So I would like to have the same centering constraint on user-defined penalized coefficient groups like it is implemented for the spline smoothing terms. The reason is that I have actually a factor coding different regions, and the penalty matrix results from the neighborhood structure in a Gaussian Markov Random Field (GMRF). So I can't choose one region as the reference category, because then the structure in the other regions would not contain the same information as before... Is there a way to constraint a group of coefficients to sum to zero? Thanks in advance, Daniel Sabanes -- Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK +44 1225 386603 www.maths.bath.ac.uk/~sw283 __ 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] (no subject)
Dear Glenn, Are you looking for str()? Try str(bycontract) HTH, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens glenn Verzonden: maandag 9 februari 2009 11:13 Aan: r-help@r-project.org Onderwerp: [R] (no subject) Is there a general method for finding out what something is in R please. I have a list (bycontract) that; is.list(bycontract3) [1] TRUE And an element of this list would be this say; bycontract3[[1]] [1] 22 3.2 -8 -17 49 3 [7] 30 -3 -21 8 3 12 [13] 49 19 -13 -2 25 39 [19] -12 -90 -1 15 -87 30 I can not seem to see what type of object this element is (is.list = FALSE) - also is there a way to take all the elements and just put them in just one series please Regards glenn [[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. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ 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] installing R on Ubuntu
On 02/09/09 10:06, Gavin Simpson wrote: On Sun, 2009-02-08 at 16:21 -0500, Jonathan Baron wrote: As much as I love Fedora (and I've used it from Core 1 onwards and haven't been swayed by Ubuntu's lovely brownness), I should point out that it need *not* be as simple as you make out on Fedora. Your install.packages(foo) invocation does require that you have installed all the build tools and development packages required to compile foo from source. Sorry. Instead of yum install R I should have said yum install R-devel I believe that this will install all the build tools needed for almost all packages, as well as R itself and its dependencies. I admit I had trouble with rgl, which compiled on one computer and not another (both with Fedora). That was the only time this has happened to me in 3 years. The error message said it required glu.h. (Googling for that discovers many problems, many on Ubuntu forums!) This is part of mesa-libGLU-devel, which should probably be listed as a dependency of R-devel. This is a bug. Bugs happen, even in Ubuntu. On finzi.psych.upenn.edu (my R site), for many years, I had all R packages installed except the ones that were for Windows only. In the last year, to save time and the computer, I've started building the help files only, except for the smaller and smaller proportion that I actually use. Jon -- Jonathan Baron, Professor of Psychology, University of Pennsylvania Home page: http://www.sas.upenn.edu/~baron __ 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] Best 64-bit Linux distro for R?
KMSL wrote: I'm running R on the current version of Gentoo and had no trouble building the complete system required. The only problem is that the current version in portage (stable) is 2.7.2. The latest _stable_ version (in terms of Gentoo's testing and release policy, NOT R's) is 2.7.2 as you note, but dev-lang/R-2.8.1 is already in portage (I usually request a version bump in Bugzilla when a new version of R or ESS is released). I have no problems running R-2.8.1 (although I am on ARCH=x86), and I have system-wide set ACCEPT_KEYWORDS=~x86 so I always get the unstable versions installed (and duly report back on bugs I encounter with R and other packages). If you don't want to go to testing on your system you can install the newer version of R by adding the relevant entry to /etc/portage/package.keywords... echo 'dev-lan/R' /etc/portage/package.keywords emerge -uDNa dev-lang/R Besides which its easy to bump the version in a local overlay yourself, but I shan't digress further, Neil -- View this message in context: http://www.nabble.com/Best-64-bit-Linux-distro-for-R--tp21904191p21911267.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] Problem about SARMA model forcasting
First of all, sorry to *Gerard. *I have changed my email account, and I don't know how to reply to my posted thread before. So I just create a new message here. Thanks again for your help! Now I realized where my mistake is. I forgot to include the seasonal differencing order. After I corrected the formula as below: (*S-ARIMA(p,d,q)*(P,D,Q)* models, where *p=1,d=0,q=1; P=0,D=1,Q=1;* and *the seasonal period S=45*.) X(t) = X(t-45) + ar1*X(t-1) - ar1*X(t-46) - ma1*a(t-1) - sma1*a(t-45) + ma1*sma1*a(t-46) + a(t) Thus, we get: a(t) = X(t) - ar1*X(t-1) - X(t-45) + ar1*X(t-46) + ma1*a(t-1) + sma1*a(t-45) - ma1*sma1*a(t-46), *when t=46*; Now my question is that: *What is the initial value of a(t) when t46? *And what is the initial setting in R? Because R gives a very good forcasting of the analyzed data series, and I just can not reproduced the results in other software (like EXCEL). Hope some one to help! Thanks! saji from Shanghai [[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] Problem in appending a row to *.csv file
For some clever reason, write.csv won't let you set col.names argument to FALSE, but you can use it with write.table using sep=,. A self-contained, minimal, and working example: write.csv(matrix(1:10,2,5), test.csv) write.table(matrix(11:20,2,5), test.csv, sep=,, append=TRUE, col.names=FALSE) Regards, KK On Mon, Feb 9, 2009 at 12:17 PM, venkata kirankumar kiran4u2...@gmail.comwrote: Hi all, I am new to R-project I have a problem when when ever I am going to append a row in a *.csv file that is in R-project I created one dataframe and I saved it in res.csv and again I got some results in dataframe with same column names and i tried to append in a new row of same res.csv file but its appending again with columnnaes like first time when i created the csv file ,max,min,avg 1,22,7,12.98333 and when I try to append another column for this file its writing like ,max,min,avg 1,22,7,12.98333 ,max,min,avg 1,19,7,12.9918699186992 can any one suggest how to solve this problem and how can I save new rows without taking column names and also i tried withappend() function to append to dataframes then also its giving the same result thanks in advance [[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] Assigning to a vector while keeping the attributes
Hi, I would like to know how to assign values to a whole vector while keeping its attributes. For example, say I have a - structure(1:3,x=3) and I want to change the values to 2:4. If I do, a - 2:4, the attribute x will be lost. I have a workaround for this case, which is to use subset assignment a[1:3] - 2:4. However, what if I want to also change the length of a? Then this workaround doesn't work and also assigning into length(a) drops the attributes. More severe workarounds (such as keeping the attributes and then reassigning them) work, but if there's a simple solution, I'd be happy to use it. Thanks, Alon [[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] length of object in repeated measures
This should do it for you: x - read.table('clipboard', header=TRUE) x Id age mass 1 1 1 5.4 2 1 3 6.2 3 1 15 10.0 4 2 3 8.1 5 2 10 12.8 6 3 2 5.9 7 3 10 7.1 8 3 15 15.4 9 3 17 16.2 x$NoCap - ave(x$Id, x$Id, FUN=length) x Id age mass NoCap 1 1 1 5.4 3 2 1 3 6.2 3 3 1 15 10.0 3 4 2 3 8.1 2 5 2 10 12.8 2 6 3 2 5.9 4 7 3 10 7.1 4 8 3 15 15.4 4 9 3 17 16.2 4 On Mon, Feb 9, 2009 at 7:36 AM, clion birt...@hotmail.com wrote: Hi there. I collectad data of several animals (Id) that were caught and measured at several occasions. The dataframe looks like this: Grouped Data: mass ~ age | Id Id age mass 11 5.4 13 6.2 1 15 10.0 23 8.1 2 10 12.8 32 5.9 3 10 7.1 3 15 15.4 3 17 16.2 Now, I would like to add a column that shows the number of captures per Animal (so it'll look like this:) Id NoCaps 1 3 1 3 1 3 2 2 2 2 3 4 3 4 I understand that with tapply(Id,Id, length) I can find out how many times each animal was caught, but how do I get this information into an extra column? I'm sure, this is an easy question, but I'm lost, where to find the answer, or especially where to look it up. if this is not a new question, please give me the key words to look for it... thanks in advance -- View this message in context: http://www.nabble.com/length-of-object-in-repeated-measures-tp21911978p21911978.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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] length of object in repeated measures
in this case you can use ave(), e.g., say 'dat' is the name of your data frame, then try this: dat$NoCaps - ave(dat$Id, dat$Id, FUN = length) dat I hope it helps. Best, Dimitris clion wrote: Hi there. I collectad data of several animals (Id) that were caught and measured at several occasions. The dataframe looks like this: Grouped Data: mass ~ age | Id Id age mass 11 5.4 13 6.2 1 15 10.0 23 8.1 2 10 12.8 32 5.9 3 10 7.1 3 15 15.4 3 17 16.2 Now, I would like to add a column that shows the number of captures per Animal (so it'll look like this:) Id NoCaps 1 3 1 3 1 3 2 2 2 2 3 4 3 4 I understand that with tapply(Id,Id, length) I can find out how many times each animal was caught, but how do I get this information into an extra column? I'm sure, this is an easy question, but I'm lost, where to find the answer, or especially where to look it up. if this is not a new question, please give me the key words to look for it... thanks in advance -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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] installing R on Ubuntu
The preceived difficulty of installing R under whatever flavour of GNU/Linux in this thread stems from being unfamiliar with the process of the package management of the flavour of GNU/Linux you use (and in part by the various distros not having the most recent version of R in their repositories People who say why can't it be as easy as dowloading a self-installing binary and running that are trying to fit a round peg (their experience and understanding of how applications install in M$-windows) in a square hole (or triangular, hexagonal, or whatever depending on the distribution of GNU/Linux). There are pro's and con's to each of the GNU/Linux flavours and its really a matter of deciding which you like/have invested time in learning. Irrespective its still simple to install R from source under GNU/Linux... 1) Download source tar-ball 2) Extract and cd to the directory 3) ./configure --prefix=/where/you/want/R/to/go (optionally setting the install path at this stage) 4) ./make 5) ./make install ...all documented in the FAQ at http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Unix_0029 This might not be as clean as using the native package management, but does mean that you'll have the latest version installed. Neil (Addendum - I've tried several different distros, starting with RedHat 7.3, then various versions of Slackware 8 through to 9 before settling on Gentoo, all were easy to install R in). -- View this message in context: http://www.nabble.com/installing-R-on-Ubuntu-tp10025949p21912206.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 on computing Geary's C statistic to test for Spatial Autocorrelation
R User ruser180 at gmail.com writes: Dear Users: I have been trying to use the geary.test() function in *R*, but am having slight difficulty understanding how I am to apply it in my context. I have 2 matrices: 1) *n x p* matrix of *n* observations with *p* measurements each. It may be noted that this matrix has a spatial dimension to it, as the *n*observations are at different geographical locations on a map. 2) *n x n* spatial weights matrix (symmetric) with each matrix element being an inter-locality weight. You sent this message to me off-list, as well as to this list, not R-sig-geo. Using a general list for specific questions is not a good idea, and asking on the list after expecting the package maintainer to get up in the middle of his/her sleep just to answer your question isn't either. If you read the ?geary.test, you would see that you require a single variable, so analyse each of your columns in turn. You have a weights matrix, but geary.test() needs a listw object, so use mat2listw() to construct it. RSiteSearch() on Geary test takes you directly to the function you need, but for listw matrix the hits are a bit more diffuse. Roger Bivand Using the above 2 matrices, I am trying to compute the Geary's *C* statistic for each of the *p* dimensions and also obtain corresponding *p*-values to determine its statistical significance for spatial autocorrelation. I will appreciate any help you could provide me in helping me compute the same. Thanks. __ 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] length of object in repeated measures
this is good, but it doesn't solve my main problem (which I unfortunately din't post - very sorry ) I would like to filter may data , for example by: dat.sub-dat[dat$age10 dat$NoCaps2,] So I need a column where the number of Captures is repeated for all rows of each captured animal. (or is there a better way to get a subset?) thanks. Dimitris Rizopoulos-4 wrote: in this case you can use ave(), e.g., say 'dat' is the name of your data frame, then try this: dat$NoCaps - ave(dat$Id, dat$Id, FUN = length) dat I hope it helps. Best, Dimitris clion wrote: Hi there. I collectad data of several animals (Id) that were caught and measured at several occasions. The dataframe looks like this: Grouped Data: mass ~ age | Id Id age mass 11 5.4 13 6.2 1 15 10.0 23 8.1 2 10 12.8 32 5.9 3 10 7.1 3 15 15.4 3 17 16.2 Now, I would like to add a column that shows the number of captures per Animal (so it'll look like this:) Id NoCaps 1 3 1 3 1 3 2 2 2 2 3 4 3 4 I understand that with tapply(Id,Id, length) I can find out how many times each animal was caught, but how do I get this information into an extra column? I'm sure, this is an easy question, but I'm lost, where to find the answer, or especially where to look it up. if this is not a new question, please give me the key words to look for it... thanks in advance -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ 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. :wistle::wistle::rules::rules::rules: -- View this message in context: http://www.nabble.com/length-of-object-in-repeated-measures-tp21911978p21912355.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] Generating missingness on SNP data
Dear all, I generated a dataset with 500 unrelated individuals and 10 biallelic SNPs. From this dataset,I would like to create data with 5% missingness on genotype information at random and also data with 5% genotyping error. Can someone help me with how I can do it. [[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] question about mean
Rolf Turner wrote: On 9/02/2009, at 4:40 PM, bill.venab...@csiro.au wrote: Store your 'matrix' as a data frame. Surely it's a data frame already, since ``school'' is character or factor, and ``value'' is (must be?) numeric. People have this unfortunate predilection to refer to data frames as matrices, and this messes them, and everybody else, up. still, a naive user's messing up data frames with matrices seems no worse than an experrienced (?) r programmer's messing up lists with vectors. 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.
Re: [R] Error installing rjags in Ubuntu Linux
Dirk helped me by pointing out some other downloads I needed in another thread to get updates working with R. After I got that working, in answer to this question, I installed rjags and it worked...next came R2jags, and I ran my first JAGS example with Gelman's school example. Success! Many thanks to all. Frank E Harrell Jr wrote: Paul Heinrich Dietrich wrote: Hi Frank, Thanks for the suggestion. It looks like that is an excellent way to install JAGS. I've also been successful with installing JAGS, but cannot get the rjags package to install, so I can call JAGS from R. Any suggestions there? Thanks. After getting jags installed, I did not encounter problems running just install.packages('rjags'). You might provide some details to the group and someone may spot the problem. Frank Frank E Harrell Jr wrote: See if this helps:http://biostat.mc.vanderbilt.edu/JAGSInstallExample Improvements to this approach are welcomed. Frank Paul Heinrich Dietrich wrote: Hi, Here is a step-by-step guide to exactly how I've installed R in Ubuntu: http://www.nabble.com/installing-R-on-Ubuntu-td10025949.html#a21894865 Regarding rjags, here is what happened: This webpage (http://yusung.blogspot.com/2009/01/install-jags-and-rjags-in-fedora.html) recommends logging into R as sudo R, and then typing: install.packages(rjags, configure.args=--with-jags-include=/usr/local/include/JAGS --with-jags-lib=/usr/local/lib/JAGS --with-jags-modules=/usr/local/lib/JAGS/modules) ...but I get... Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/local/lib/R/site-library/rjags/libs/rjags.so': ...which is virtually identical to this thread (http://www.nabble.com/unable-to-install-rjags-on-64-bit-Debian-Linux-(etch)-td20404210.html#a20404210) about a 64-bit install. Although my computer has dual AMD64's, I'm sure it's a 32-bit system. I have removed rjags with remove.packages(rjags). Does anybody know how to install rjags in Ubuntu Linux (I'm specifying it, because I am very new and don't know what I'm doing yet)? Thanks. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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/Error-installing-rjags-in-Ubuntu-Linux-tp21900345p21911131.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] Problems in Recommending R
[coming late to an interesting thread ...] Ao == Ajay ohri ohri2...@gmail.com on Mon, 2 Feb 2009 18:14:03 +0530 writes: Ao Plain HTML coding is simple enough for this list ( I think)...but aesthetic Ao designhmm I tend to agree. A few months ago, we had volunteers to improve the ESS homepage (http://ess.r-project.org/), and I had asked for a similar .. but different! .. restriction : Yes: the result should be maintainable by SVN BUT: it can depend on server-side functionality Consequently, the two volunteers, Domenico Vistocco and Wilmar Igl, confined the code to using PHP (+ HTML + CSS), and while the result is not as if it had be done by (highly paid!) professional designers, it is a big step forward, and we've been very grateful for Domenico's and Wilmar's initiative and its result. Ao But a contest would the best way to get the best design and can be Ao publicly asked from the graphics community ( not just the R Ao community)..remember Tom Sawyer and the fence :) I would find it fun to have a contest on this... with the restriction of ASCII-files (+ a few pics) maintainable by SVN but *not* restricting it to no-server-side modules required. Martin Maechler, ETH Zurich Ao - I volunteer in both cases :) Ao Winner of Design Contest should get Ao some bragging rights in a small hyperlink (with nofollow tag -so no seo) Ao on main page ,French Wine in the user conference location , Ao etc etc... Ao On Mon, Feb 2, 2009 at 5:26 PM, friedrich.lei...@stat.uni-muenchen.dewrote: On Mon, 02 Feb 2009 08:44:21 +0100, Thomas Petzoldt (TP) wrote: Hi, you are probably right, though I must say that I like *spartanic and efficient* homepages and I don't think that the example given by the first mail is a good prototype for the R homepage. But, yes, occasional face lifting may be adequate. Anti-aliasing is of course simple, but that's probably not the point. (And I know that there are graphics experts with a masters in psychology between us.) So, why not a new Homepage Graphics Competition 2009? There is still some time until useR!2009 in Rennes: http://www2.agrocampus-ouest.fr/math/useR-2009/ Perhaps we should extend that to a competition for the complete design of the homepage? We often get emails like the first in this thread that R could do with an update on homepage design (I fully agree) ... but actually nobody volunteers to do it. Hence, we still have what I did when the worldwide number of R users was probably less than 1000. For technical reasons there are some conditions: the homepage is maintained via SVN like the R sources, so all should be plain HTML, no content management system etc. Ad frames: the main reason that I used them in the first place is to have the menus etc in only one file, no need for updating several files when a link changes. Today I would probably use iframes, but any other soultion is fine, too. Another plus would be if we could use the same design for CRAN, and that means no server-trickery like server-side includes etc (because we do not control the server setup of the mirrors). Best, Fritz -- --- Prof. Dr. Friedrich Leisch Institut für Statistik Tel: (+49 89) 2180 3165 Ludwig-Maximilians-Universität Fax: (+49 89) 2180 5308 Ludwigstraße 33 D-80539 München http://www.statistik.lmu.de/~leisch --- Journal Computational Statistics --- http://www.springer.com/180 Münchner R Kurse --- http://www.statistik.lmu.de/R __ 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. Ao [[alternative HTML version deleted]] Ao __ Ao R-help@r-project.org mailing list Ao https://stat.ethz.ch/mailman/listinfo/r-help Ao PLEASE do read the posting guide http://www.R-project.org/posting-guide.html Ao 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] Problems in Recommending R
For redesigning functionality , some input must be given to the path of web pages followed by users. This would rely on the current analytics software installed on the main website (?) . I use a software called called clicky from www.getclicky.com and use the user input to tweak pages,posts including time of pause at web pages. I can also in addition to the coding of the HTML, CSS help with the online analytics for the website- It is actually best if someone who knows the users is given the row level records ( which is done in clicky but not in Google Analytics) Some websites offer a choice at the entrance - light HTML version and heavy Flash version. This can be done as well just for the main pages (2-3) ,and then link to the same cran page . Given that next website upgrade (after this one!) would take some years- There could be section for leading R blogs/practitioners, as well as some social networking links (Twitter) and a Journal /Books Recommended page .There could also be spaces for Video Tutorial ( Embed only in HTML ) from other sides. This group can also meet /talk via voice talk ( using skype or Gtalk) if possible on getting this project ahead- chaired by Moderator and Co-ordinator of the project. Best Regards, Ajay www.decisionstats.com Doug Larson - Instead of giving a politician the keys to the city, it might be better to change the locks. On Mon, Feb 9, 2009 at 7:05 PM, Martin Maechler maech...@stat.math.ethz.ch wrote: [coming late to an interesting thread ...] Ao == Ajay ohri ohri2...@gmail.com on Mon, 2 Feb 2009 18:14:03 +0530 writes: Ao Plain HTML coding is simple enough for this list ( I think)...but aesthetic Ao designhmm I tend to agree. A few months ago, we had volunteers to improve the ESS homepage (http://ess.r-project.org/), and I had asked for a similar .. but different! .. restriction : Yes: the result should be maintainable by SVN BUT: it can depend on server-side functionality Consequently, the two volunteers, Domenico Vistocco and Wilmar Igl, confined the code to using PHP (+ HTML + CSS), and while the result is not as if it had be done by (highly paid!) professional designers, it is a big step forward, and we've been very grateful for Domenico's and Wilmar's initiative and its result. Ao But a contest would the best way to get the best design and can be Ao publicly asked from the graphics community ( not just the R Ao community)..remember Tom Sawyer and the fence :) I would find it fun to have a contest on this... with the restriction of ASCII-files (+ a few pics) maintainable by SVN but *not* restricting it to no-server-side modules required. Martin Maechler, ETH Zurich Ao - I volunteer in both cases :) Ao Winner of Design Contest should get Ao some bragging rights in a small hyperlink (with nofollow tag -so no seo) Ao on main page ,French Wine in the user conference location , Ao etc etc... Ao On Mon, Feb 2, 2009 at 5:26 PM, friedrich.lei...@stat.uni-muenchen.dewrote: On Mon, 02 Feb 2009 08:44:21 +0100, Thomas Petzoldt (TP) wrote: Hi, you are probably right, though I must say that I like *spartanic and efficient* homepages and I don't think that the example given by the first mail is a good prototype for the R homepage. But, yes, occasional face lifting may be adequate. Anti-aliasing is of course simple, but that's probably not the point. (And I know that there are graphics experts with a masters in psychology between us.) So, why not a new Homepage Graphics Competition 2009? There is still some time until useR!2009 in Rennes: http://www2.agrocampus-ouest.fr/math/useR-2009/ Perhaps we should extend that to a competition for the complete design of the homepage? We often get emails like the first in this thread that R could do with an update on homepage design (I fully agree) ... but actually nobody volunteers to do it. Hence, we still have what I did when the worldwide number of R users was probably less than 1000. For technical reasons there are some conditions: the homepage is maintained via SVN like the R sources, so all should be plain HTML, no content management system etc. Ad frames: the main reason that I used them in the first place is to have the menus etc in only one file, no need for updating several files when a link changes. Today I would probably use iframes, but any other soultion is fine, too. Another plus would be if we could use the same design for CRAN, and that means no server-trickery like server-side includes etc (because we do not control the server setup of the mirrors). Best, Fritz -- --- Prof. Dr. Friedrich Leisch Institut für Statistik
Re: [R] general inverse solver?
Carl: I don't know if this is helpful or not, but have you seen the functions backsolve and forwardsolve for solving triangular systems? -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Carl Witthoft Sent: Sunday, February 08, 2009 3:12 PM To: r-help@r-project.org Subject: [R] general inverse solver? Just wondering if there's an R package which does tricks similar to what TK!Solver does. TK!Solver, for those not lucky enough to have found it, basically allows one to define a bunch of equations, assign values to an arbitrary subset of the variables, from which it calculates (either directly when possible or back-solving when not) the values of the other variable(s). thanks Carl __ 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] questions for randomFroest package
Hi, I try to use randomFroest package to run SNP data analysis. I have the following questions. 1. Can the outcome variables in Random Forests be binary or continuous? 2. Can the covariates in Random Forests be continuous or categorical? 3. How to define which variables (both outcome and covariates) are categorical variables in this randomFroest package ? 4. What is the SNP data format for this package? Could I use (0, 1, 2) for a SNP? Thanks! Whitney [[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] (no subject)
You first need to look at the documentation for the mode, class and typeof functions. (This should have been covered early in any of the standard texts.) You are using the function [[ on a list with one element and it appears you are getting a vector. Try: is.vector(bycontract[[1]]) mode(bycontract) class(bycontract) typeof(bycontract) this.thing - bycontract[[1]] mode(this.thing) class(this.thing) typeof(this.thing) Now you have in this.thing what some people outside R might call just one series, but R users would call a vector. There are very useful indexed series objects of class zoo, but it doesn't appear as though you are quite ready for that level of complexity. Install and load the zoo package for addition of that facility when you are ready . -- David Winsemius in this case On Feb 9, 2009, at 5:13 AM, glenn wrote: Is there a general method for finding out what something is in R please. I have a list (bycontract) that; is.list(bycontract3) [1] TRUE And an element of this list would be this say; bycontract3[[1]] [1] 22 3.2 -8 -17 49 3 [7] 30 -3 -21 8 3 12 [13] 49 19 -13 -2 25 39 [19] -12 -90 -1 15 -87 30 I can not seem to see what type of object this element is (is.list = FALSE) - also is there a way to take all the elements and just put them in just one series please Regards glenn [[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.
[R] standardize
Very quick newbie question sorry; How do I standardize a list of data please (other than do the calculation of course). Is there a quick way please ? glenn [[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] (no subject)
Hi, I'm trying to create a connectivity diagram using RgraphViz library. I want to increase the edge's label fontsize, but the size did not change. Did I do something wrong ? M - matrix(nrow=5,ncol=5,byrow=TRUE,data=mytable) colnames(M) - levels(pf$agent) A - new(graphAM, M, directed, values = list(weight=M)) eAttrs - list() ew - as.character(unlist(edgeWeights(A))) names(ew) - edgeNames(A, recipEdges = distinct) eAttrs$label - ew fs2 - rep(c(72), length(ew)) names(fs2) - edgeNames(A, recipEdges = distinct) eAttrs$labelfontsize - fs2 plot(A, attrs = list(node = list(label = foo, fillcolor = lightblue), edge = list(color = red)), edgeAttrs = eAttrs,recipEdges=distinct) Thanks. __ 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] standardize
Hi, Maybe you are looking for scale( x ) Regards Patricia From: g1enn.robe...@btinternet.com To: r-help@r-project.org Date: Mon, 9 Feb 2009 14:09:04 + Subject: [R] standardize Very quick newbie question sorry; How do I standardize a list of data please (other than do the calculation of course). Is there a quick way please ? glenn [[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] Problem in appending a row to *.csv file
Looking at your question, I found myself wondering if you really wanted to do this at all. It appeared so much like inefficient habits acquired in the years of BASIC and Excel use. If you are interested in storing a dataframe to disk and then bringing it back into an R session, then the save and load functions are more appropriate. Append works on vectors (and apparently on lists although the append help page does not document that behavior), but will probably not have the desired effect on dataframes. Look instead at the rbind function if you are interested in adding row- wise to a dataframe. tail(DF) Month Week Estpassage MedFL 8Aug 34 35854135 9 Sept 35 74783935 10 Sept 36 45968236 11 Sept 37 60956736 12 Sept 38 97947536 13 Sept 39 83718936 tail( rbind(DF, c(Aug, 36, 555, 44)) ) Month Week Estpassage MedFL 9 Sept 35 74783935 10 Sept 36 45968236 11 Sept 37 60956736 12 Sept 38 97947536 13 Sept 39 83718936 14 Aug 3655544 -- David Winsemius On Feb 9, 2009, at 5:17 AM, venkata kirankumar wrote: Hi all, I am new to R-project I have a problem when when ever I am going to append a row in a *.csv file that is in R-project I created one dataframe and I saved it in res.csv and again I got some results in dataframe with same column names and i tried to append in a new row of same res.csv file but its appending again with columnnaes like first time when i created the csv file ,max,min,avg 1,22,7,12.98333 and when I try to append another column for this file its writing like ,max,min,avg 1,22,7,12.98333 ,max,min,avg 1,19,7,12.9918699186992 can any one suggest how to solve this problem and how can I save new rows without taking column names and also i tried withappend() function to append to dataframes then also its giving the same result thanks in advance [[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] uniroot() problem
Megh, The problem is due to jump discontinuity in your function at x=0. It is always good practice to plot the function over the range of interest. x - seq(-20, 20, by=0.01) plot(x, th.price(x), type=l) This will reveal the problem. The function value jumps from -384.4 to 36.29 at x=0. If the singularity at x=0 is not an essential one, you may be able to anayticallty remove this singularity. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of megh Sent: Monday, February 09, 2009 4:27 AM To: r-help@r-project.org Subject: Re: [R] uniroot() problem Thanks for this reply. Here I was trying to calculate implied volatility using BS formula. This is my code : oo = 384.40 # traded option price uu = 1563.25 # underlying price tt = 0.656 # time to maturity in year ii = 2.309/100 # interest rate, annualized th.price = function(x) { d1 = (log(uu/K) + (ii + x^2/2)*tt) / (x*sqrt(tt)); d2 = d1 - x*sqrt(tt) option.price = uu * pnorm(d1) - K * exp(-ii*tt) * pnorm(d2) return(option.price - oo) } uniroot(th.price, c(-20, 20), tol=1/10^12) I got following result : uniroot(th.price, c(-20, 20), tol=1/10^12) $root [1] 6.331672e-13 $f.root [1] 36.28816 $iter [1] 55 $estim.prec [1] 7.385592e-13 Hence using implied volatility, difference between traded price and theoretical price is coming as high as 36.28816, even I increse the precision level. Any idea how to crack this problem? Albyn Jones wrote: One can't tell for sure without seeing the function, but I'd guess that you have a numerical issue. Here is an example to reflect upon: f=function(x) (exp(x)-exp(50))*(exp(x)+exp(50)) uniroot(f,c(0,100)) $root [1] 49.7 $f.root [1] -1.640646e+39 $iter [1] 4 $estim.prec [1] 6.103516e-05 .Machine$double.eps^0.25/2 [1] 6.103516e-05 uniroot thinks it has converged, at least in relative terms. Note that the estimated precision is related to the machine epsilon, used in the default value for tol. try fiddling with the tol argument. uniroot(f,c(0,100),tol=1/10^12) $root [1] 50 $f.root [1] 1.337393e+31 $iter [1] 4 $estim.prec [1] 5.186962e-13 albyn Quoting megh megh700...@yahoo.com: I have a strange problem with uniroot() function. Here is the result : uniroot(th, c(-20, 20)) $root [1] 4.216521e-05 $f.root [1] 16.66423 $iter [1] 27 $estim.prec [1] 6.103516e-05 Pls forgive for not reproducing whole code, here my question is how f.root can be 16.66423? As it is finding root of a function, it must be near Zero. Am I missing something? -- View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21227702.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. -- View this message in context: http://www.nabble.com/uniroot%28%29-problem-tp21227702p21909423.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] R equivalent of SAS Cochran-Mantel-Haenszel tests?
In SAS, for a two-way (or 3-way, stratified) table, the CMH option in SAS PROC FREQ gives 3 tests that take ordinality of the factors into account, for both variables, just the column variable or neither. Is there an equivalent in R? The mantelhaen.test in stats gives something quite different (a test of conditional independence for *nominal* factors in a 3-way table). e.g. I'd like to reproduce: *-- CMH tests; proc freq data=sexfun order=data; weight count; tables husband * wife / cmh chisq nocol norow; run; The FREQ Procedure Summary Statistics for Husband by Wife Cochran-Mantel-Haenszel Statistics (Based on Table Scores) StatisticAlternative HypothesisDF Value Prob 1Nonzero Correlation1 10.01420.0016 2Row Mean Scores Differ 3 12.56810.0057 3General Association9 16.76890.0525 -- 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] Re turn values 0 from Matrix
If your matrix is called mat, how about mat[which(mat[,2] 0), ] mat[which(mat[,2] 0), ] -Ian mentor_ wrote: Hi, I have a matrix with negative and positiv values. How can I get either the negative or positive values from the matrix? Matrix: [,1] [,2] [1,]1 -3 [2,]2 -2 [3,]35 [4,]4 -2 [5,]59 [6,]68 [7,]7 -2 What I want to have is: [,1] [,2] [1,]1 -3 [2,]2 -2 [3,]4 -2 [4,]7 -2 and: [,1] [,2] [1,]35 [2,]59 [3,]68 Regards -- View this message in context: http://www.nabble.com/Return-values-%3C-0-from-Matrix-tp21913440p21914262.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] Assigning to a vector while keeping the attributes
Not sure what a really is. It's not a vector or a list according to the R interpreter. a - structure(1:3,x=3) mode(a) [1] numeric is.vector(a) [1] FALSE is.list(a) [1] FALSE Experimentation shows that simple indexing provides the functionality you request while append does not. a[4] - 10 a [1] 1 2 3 10 attr(,x) [1] 3 a -append(a, 20) a [1] 1 2 3 10 20 # appears to have now coerced it to a vector a [1] 1 2 3 10 20 is.vector(a) [1] TRUE -- David Winsemius On Feb 9, 2009, at 7:09 AM, Alon Wasserman wrote: Hi, I would like to know how to assign values to a whole vector while keeping its attributes. For example, say I have a - structure(1:3,x=3) and I want to change the values to 2:4. If I do, a - 2:4, the attribute x will be lost. I have a workaround for this case, which is to use subset assignment a[1:3] - 2:4. However, what if I want to also change the length of a? Then this workaround doesn't work and also assigning into length(a) drops the attributes. More severe workarounds (such as keeping the attributes and then reassigning them) work, but if there's a simple solution, I'd be happy to use it. Thanks, Alon [[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] length of object in repeated measures
On Mon, Feb 9, 2009 at 8:03 AM, clion birt...@hotmail.com wrote: this is good, but it doesn't solve my main problem (which I unfortunately din't post - very sorry ) I would like to filter may data , for example by: dat.sub-dat[dat$age10 dat$NoCaps2,] So I need a column where the number of Captures is repeated for all rows of each captured animal. (or is there a better way to get a subset?) Well, you could use merge: dat - data.frame( id=c(1,1,1,2,2,2,3), age=c(2,3,4,2,3,5,3), mass=c(1,2,3,2,3,4,3) ) caps - tapply(an$id,an$id,length) merge(dat,caps,by.x=1,by.y=0) id age mass y 1 1 21 3 2 1 32 3 3 1 43 3 4 2 22 3 5 2 33 3 6 2 54 3 7 3 33 1 [[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] installing R on Ubuntu
At 07:58 09/02/2009, Thomas Lumley wrote: On Sun, 8 Feb 2009, Tom Backer Johnsen wrote: Dirk Eddelbuettel wrote: On 8 February 2009 at 20:36, Tom Backer Johnsen wrote: | Dear me. Is the installation of R under Ubuntu really that complex? I | have a dual boot machine (Linux / Windows, where I use the latter the | most) and have plans to try R under Linux, but have not done so yet. Is | it possible to simplify the Linux install procedure to make R more | accessible to novices? Yes. 'sudo apt-get install r-base ess ggobi' and you have working R, ESS and Ggobi. Start Emacs, type 'M-x R' and you have an R session inside Emacs. Is that really easier to accomplish in Windows? No. If it is that simple to install R under a Debian vaiant of Linux, it definitely is easier. On the other hand, using Emacs is not (as far as I know) the thing for novices. What I would prefer is something that is as simple to use as the Windows (or even better, the Mac interface) for R. Tom, For what it is worth 1 - as a long term Windows user and complete Linux novice I found the process on Linux (using the Debian pages at CRAN and the r-sig-debian help list as an instruction set) fairly straightforward. Some things are easier, some harder. 2 - if all you want is a simple editor with syntax highlighting and the ability to pipe commands to the running R then you could consider Kate which you may already have. It is of course also much more powerful than that but you can effortlessly ignore the powerful bits. Plus Kate is a cute name. You might like JGR, then. http://jgr.markushelbig.org/JGR.html -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle Michael Dewey http://www.aghmed.fsnet.co.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.
Re: [R] Re turn values 0 from Matrix
I still remember my public spanking from Ben Bolker on the unnecessary use of which in this instance. MM - matrix(c(1:10,sample(-10:10,10)),nrow=10) MM [,1] [,2] [1,]1 -1 [2,]25 [3,]3 -2 [4,]4 -3 [5,]50 [6,]67 [7,]7 -9 [8,]81 [9,]96 [10,] 104 MM[MM[,2]0, ] [,1] [,2] [1,]1 -1 [2,]3 -2 [3,]4 -3 [4,]7 -9 MM[MM[,2]0, ] [,1] [,2] [1,]25 [2,]67 [3,]81 [4,]96 [5,] 104 -- David Winsemius On Feb 9, 2009, at 9:46 AM, Ian Fiske wrote: If your matrix is called mat, how about mat[which(mat[,2] 0), ] mat[which(mat[,2] 0), ] -Ian mentor_ wrote: Hi, I have a matrix with negative and positiv values. How can I get either the negative or positive values from the matrix? Matrix: [,1] [,2] [1,]1 -3 [2,]2 -2 [3,]35 [4,]4 -2 [5,]59 [6,]68 [7,]7 -2 What I want to have is: [,1] [,2] [1,]1 -3 [2,]2 -2 [3,]4 -2 [4,]7 -2 and: [,1] [,2] [1,]35 [2,]59 [3,]68 Regards -- View this message in context: http://www.nabble.com/Return-values-%3C-0-from-Matrix-tp21913440p21914262.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] Assigning to a vector while keeping the attributes
Try this: a - structure(1:3, x = 3) b - attributes-(11:15, attributes(a)) dput(b) On Mon, Feb 9, 2009 at 7:09 AM, Alon Wasserman alon@gmail.com wrote: Hi, I would like to know how to assign values to a whole vector while keeping its attributes. For example, say I have a - structure(1:3,x=3) and I want to change the values to 2:4. If I do, a - 2:4, the attribute x will be lost. I have a workaround for this case, which is to use subset assignment a[1:3] - 2:4. However, what if I want to also change the length of a? Then this workaround doesn't work and also assigning into length(a) drops the attributes. More severe workarounds (such as keeping the attributes and then reassigning them) work, but if there's a simple solution, I'd be happy to use it. Thanks, Alon [[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] R equivalent of SAS Cochran-Mantel-Haenszel tests?
Dear Michael, It sounds as a linear-by-linear loglinear model (and its variants) which uses scores for one or more variables in the table.. (see Agresti, 1990, Categorical Data Analysis. I do remember the pages and I have not the book here..) If this is the case, you can use standard call to glm(.., family=poisson) with score variables in the linear predictor. For instance for a two-way table with ordered variables the linear-by-linear model is, glm(freq~factor(x)+factor(y)+I(score.x*score.y), family=poisson) The CMH test, probably, is the score test of the parameter of I(score.x*score.y).. best, vito Michael Friendly ha scritto: In SAS, for a two-way (or 3-way, stratified) table, the CMH option in SAS PROC FREQ gives 3 tests that take ordinality of the factors into account, for both variables, just the column variable or neither. Is there an equivalent in R? The mantelhaen.test in stats gives something quite different (a test of conditional independence for *nominal* factors in a 3-way table). e.g. I'd like to reproduce: *-- CMH tests; proc freq data=sexfun order=data; weight count; tables husband * wife / cmh chisq nocol norow; run; The FREQ Procedure Summary Statistics for Husband by Wife Cochran-Mantel-Haenszel Statistics (Based on Table Scores) StatisticAlternative HypothesisDF Value Prob 1Nonzero Correlation1 10.01420.0016 2Row Mean Scores Differ 3 12.56810.0057 3General Association9 16.76890.0525 -- Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Università di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 6626240 fax: 091 485726/485612 http://dssm.unipa.it/vmuggeo __ 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] Counting session days
hi, I have some session data in a dataframe, where each session is recorded with a start and a stop date. Like this: session_start session_stop === 2009-01-03 2009-01-04 2009-01-01 2009-01-05 2009-01-02 2009-01-09 A session is at least one day long. Now I want a dataframe with 'active sessions' per date. Like this: dateactive_sessions = 2009-01-01 1 2009-01-02 2 2009-01-03 3 2009-01-04 3 2009-01-05 2 2009-01-06 1 2009-01-07 1 2009-01-08 1 2009-01-09 1 How do I do that? I've searched the usual sources, but my newbie status and language barrier left me with nothing. So plz, anyone? __ 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] Counting session days
Try this: dateseq - function(i) seq(DF[i, 1], DF[i, 2], 1) table(as.Date(unlist(lapply(1:nrow(DF), dateseq)), origin = 1970-01-01)) 2009-01-01 2009-01-02 2009-01-03 2009-01-04 2009-01-05 2009-01-06 2009-01-07 1 2 3 3 2 1 1 2009-01-08 2009-01-09 1 1 On Mon, Feb 9, 2009 at 10:57 AM, stefan.peters...@inizio.se wrote: hi, I have some session data in a dataframe, where each session is recorded with a start and a stop date. Like this: session_start session_stop === 2009-01-03 2009-01-04 2009-01-01 2009-01-05 2009-01-02 2009-01-09 A session is at least one day long. Now I want a dataframe with 'active sessions' per date. Like this: dateactive_sessions = 2009-01-01 1 2009-01-02 2 2009-01-03 3 2009-01-04 3 2009-01-05 2 2009-01-06 1 2009-01-07 1 2009-01-08 1 2009-01-09 1 How do I do that? I've searched the usual sources, but my newbie status and language barrier left me with nothing. So plz, anyone? __ 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] Counting session days
On Mon, Feb 9, 2009 at 4:57 PM, stefan.peters...@inizio.se wrote: hi, I have some session data in a dataframe, where each session is recorded with a start and a stop date. Like this: session_start session_stop === 2009-01-03 2009-01-04 2009-01-01 2009-01-05 2009-01-02 2009-01-09 A session is at least one day long. Now I want a dataframe with 'active sessions' per date. Like this: dateactive_sessions = 2009-01-01 1 2009-01-02 2 2009-01-03 3 2009-01-04 3 2009-01-05 2 2009-01-06 1 2009-01-07 1 2009-01-08 1 2009-01-09 1 How do I do that? I've searched the usual sources, but my newbie status and language barrier left me with nothing. So plz, anyone? Hej Stefan, The following should do. It's a bit convoluted though, so someone else might be able to come up with a better solution. test start stop 1 2009-01-03 2009-01-04 2 2009-01-01 2009-01-05 3 2009-01-02 2009-01-09 activeDaysPerSession-apply(test,MARGIN=1,FUN=function(x) seq(from=as.Date(x[start]), to=as.Date(x[stop]),by=1 ) ) ActiveDays-as.Date(unlist(activeDaysPerSession)) as.data.frame(table(ActiveDays)) Regards, Gustaf -- Gustaf Rydevik, M.Sci. tel: +46(0)703 051 451 address:Essingetorget 40,112 66 Stockholm, SE skype:gustaf_rydevik __ 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] gee with auto-regressive correlation structure (AR-M)
Dear all, I need to fit a gee model with an auto-regressive correlation structure and I faced some problems. I attach a simple example: ### library(gee) library(geepack) # I SIMULATE DATA FROM POISSON DISTRIBUTION, 10 OBS FOR EACH OF 50 GROUPS set.seed(1) y - rpois(500,50) x - rnorm(500) id - rep(1:50,each=10) # EXAMPLES FOR EXCHANGEABLE AND AR(1) CORRELATION STRUCTURES model1 - gee(y ~ x, family=poisson(),id=id, corstr=exchangeable) model2 - gee(y ~ x, family=poisson(),id=id, corstr=AR-M) # NOW 50 OBS FOR EACH OF 10 GROUPS id2 - rep(1:10,each=50) model3 - gee(y ~ x, family=poisson(),id=id2, corstr=exchangeable) model4 - gee(y ~ x, family=poisson(),id=id2, corstr=AR-M) # ERROR model5 - geeglm(y ~ x, family=poisson(),id=id2, corstr=ar1) ## Basically, it seems that the gee command (package gee) doesn't work when the id groups are large, as in my dataset (observations from several summer seasons, for which I imagine an AR correlation structure within each season). The command geeglm (package geepack) seems to work, but provides only few corstr choices (for example not stat_M_dep, which can be useful to investigate models with different correlation structures). Any suggestions? Thanks so much for your time __ 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] installing R on Ubuntu
On Mon, Feb 9, 2009 at 4:51 AM, Neil Shephard nsheph...@gmail.com wrote: The preceived difficulty of installing R under whatever flavour of GNU/Linux in this thread stems from being unfamiliar with the process of the package management of the flavour of GNU/Linux you use (and in part by the various distros not having the most recent version of R in their repositories. People who say why can't it be as easy as dowloading a self-installing binary and running that are trying to fit a round peg (their experience and understanding of how applications install in M$-windows) in a square hole (or triangular, hexagonal, or whatever depending on the distribution of GNU/Linux). This is true. However, for the most common Linux distros --Debian, Red Hat Enterprise / CentOS / Scientific Linux / Fedora, openSUSE and Ubuntu -- you can install the most recent R compiled for your distro from http://your-nearest-CRAN-mirror/bin/linux/ In addition, most of the distros have third-party repositories where you can find the latest version of R. In short, if you have an x86 or x86_64/amd64 system running almost any Linux, you can find a pre-compiled R. R is a popular package, and it's pretty easy to find even for Power PC or some of the obscure architectures. There are pro's and con's to each of the GNU/Linux flavours and its really a matter of deciding which you like/have invested time in learning. Irrespective its still simple to install R from source under GNU/Linux... 1) Download source tar-ball 2) Extract and cd to the directory 3) ./configure --prefix=/where/you/want/R/to/go (optionally setting the install path at this stage) 4) ./make 5) ./make install ...all documented in the FAQ at http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Unix_0029 Many Linux distros do *not* install the development tools by default, and which ones live in which packages varies by distro. Fedora in particular is extremely stripped when you install from the LiveCD. You have to install gcc, make and a couple of other things just to install VMware Tools, for example, when running Fedora as a VMware guest. For building R from source and installing R packages, you'll also need to install gfortran. And many libraries with external dependencies, like Rgraphviz, will require not only the package itself (graphviz) but also the C headers, which may have the name graphviz-devel on some distros and some other name on other distros. This might not be as clean as using the native package management, but does mean that you'll have the latest version installed. Neil (Addendum - I've tried several different distros, starting with RedHat 7.3, then various versions of Slackware 8 through to 9 before settling on Gentoo, all were easy to install R in). I just recently switched from Gentoo to openSUSE. Gentoo usually had the latest R source in their repository within a day or so of it coming out of the R Project release cycle. To get it, all you needed to do was put the package name in the /etc/portage/package-keywords file. And Gentoo, since it is almost all compiled from source, by nature *does* have all the development tools installed and installs all the headers when it installs packages. -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed. __ 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 equivalent of SAS Cochran-Mantel-Haenszel tests?
Dear Vito, Yes, these tests are *similar* in spirit to loglinear models using either row/col/both scores for the association. But I'm still looking for something equivalent to give the same results as SAS with CMH for non-parametric tests. One advantage of the CMH tests is that for stratified tables, a largish sample size is not required in the individual strata, only the total n. The computations are described in: http://support.sas.com/onlinedoc/913/getDoc/en/procstat.hlp/freq_sect27.htm vito muggeo wrote: Dear Michael, It sounds as a linear-by-linear loglinear model (and its variants) which uses scores for one or more variables in the table.. (see Agresti, 1990, Categorical Data Analysis. I do remember the pages and I have not the book here..) If this is the case, you can use standard call to glm(.., family=poisson) with score variables in the linear predictor. For instance for a two-way table with ordered variables the linear-by-linear model is, glm(freq~factor(x)+factor(y)+I(score.x*score.y), family=poisson) The CMH test, probably, is the score test of the parameter of I(score.x*score.y).. best, vito Michael Friendly ha scritto: In SAS, for a two-way (or 3-way, stratified) table, the CMH option in SAS PROC FREQ gives 3 tests that take ordinality of the factors into account, for both variables, just the column variable or neither. Is there an equivalent in R? The mantelhaen.test in stats gives something quite different (a test of conditional independence for *nominal* factors in a 3-way table). e.g. I'd like to reproduce: *-- CMH tests; proc freq data=sexfun order=data; weight count; tables husband * wife / cmh chisq nocol norow; run; The FREQ Procedure Summary Statistics for Husband by Wife Cochran-Mantel-Haenszel Statistics (Based on Table Scores) StatisticAlternative HypothesisDF Value Prob 1Nonzero Correlation1 10.01420.0016 2Row Mean Scores Differ 3 12.56810.0057 3General Association9 16.76890.0525 -- 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] outer to vectors
Hi all, Having a matrix A formed by n vectors as columns. Is there anything to calculate a determined function to all combination of vectors? For example imagine A matrix is compose by vectors a, b and c. And the function to perform is correlation, so I would like to obtain cor(a, b), cor(a, c) and cor(b, c). I we had numbers instead of vector, the function is outer, but I am not able to apply it to vectors... Thanks a lot. P. Date: Mon, 9 Feb 2009 08:37:06 -0800 From: zzn...@gmail.com To: r-help@r-project.org Subject: Re: [R] installing R on Ubuntu On Mon, Feb 9, 2009 at 4:51 AM, Neil Shephard nsheph...@gmail.com wrote: The preceived difficulty of installing R under whatever flavour of GNU/Linux in this thread stems from being unfamiliar with the process of the package management of the flavour of GNU/Linux you use (and in part by the various distros not having the most recent version of R in their repositories. People who say why can't it be as easy as dowloading a self-installing binary and running that are trying to fit a round peg (their experience and understanding of how applications install in M$-windows) in a square hole (or triangular, hexagonal, or whatever depending on the distribution of GNU/Linux). This is true. However, for the most common Linux distros --Debian, Red Hat Enterprise / CentOS / Scientific Linux / Fedora, openSUSE and Ubuntu -- you can install the most recent R compiled for your distro from http://your-nearest-CRAN-mirror/bin/linux/ In addition, most of the distros have third-party repositories where you can find the latest version of R. In short, if you have an x86 or x86_64/amd64 system running almost any Linux, you can find a pre-compiled R. R is a popular package, and it's pretty easy to find even for Power PC or some of the obscure architectures. There are pro's and con's to each of the GNU/Linux flavours and its really a matter of deciding which you like/have invested time in learning. Irrespective its still simple to install R from source under GNU/Linux... 1) Download source tar-ball 2) Extract and cd to the directory 3) ./configure --prefix=/where/you/want/R/to/go (optionally setting the install path at this stage) 4) ./make 5) ./make install ...all documented in the FAQ at http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Unix_0029 Many Linux distros do *not* install the development tools by default, and which ones live in which packages varies by distro. Fedora in particular is extremely stripped when you install from the LiveCD. You have to install gcc, make and a couple of other things just to install VMware Tools, for example, when running Fedora as a VMware guest. For building R from source and installing R packages, you'll also need to install gfortran. And many libraries with external dependencies, like Rgraphviz, will require not only the package itself (graphviz) but also the C headers, which may have the name graphviz-devel on some distros and some other name on other distros. This might not be as clean as using the native package management, but does mean that you'll have the latest version installed. Neil (Addendum - I've tried several different distros, starting with RedHat 7.3, then various versions of Slackware 8 through to 9 before settling on Gentoo, all were easy to install R in). I just recently switched from Gentoo to openSUSE. Gentoo usually had the latest R source in their repository within a day or so of it coming out of the R Project release cycle. To get it, all you needed to do was put the package name in the /etc/portage/package-keywords file. And Gentoo, since it is almost all compiled from source, by nature *does* have all the development tools installed and installs all the headers when it installs packages. -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed. __ 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] R solve equation
As suggested by somebody else, uniroot() can be used to solve equations in one unknown variable. However, you will never get the exact x in R, only an approximate root... Best, Giovanni Date: Sat, 07 Feb 2009 02:20:10 -0800 (PST) From: oryie 43248...@qq.com Sender: r-help-boun...@r-project.org Precedence: list Hello! I want to use R to calculate the variable x which is in some eqation, give an example: 3*x-log(x)+1=0, how to solve equation to get the exact x in R? Thank you very much! -- View this message in context: http://www.nabble.com/R-solve-equation-tp21886831p21886831.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. -- Giovanni Petris gpet...@uark.edu 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] outer to vectors
'combn' will give you the combinations that you can then use as parameters in the function: combn(c('a', 'b', 'c'), 2) [,1] [,2] [,3] [1,] a a b [2,] b c c On Mon, Feb 9, 2009 at 11:44 AM, patricia garcía gonzález kurtney...@hotmail.com wrote: Hi all, Having a matrix A formed by n vectors as columns. Is there anything to calculate a determined function to all combination of vectors? For example imagine A matrix is compose by vectors a, b and c. And the function to perform is correlation, so I would like to obtain cor(a, b), cor(a, c) and cor(b, c). I we had numbers instead of vector, the function is outer, but I am not able to apply it to vectors... Thanks a lot. P. Date: Mon, 9 Feb 2009 08:37:06 -0800 From: zzn...@gmail.com To: r-help@r-project.org Subject: Re: [R] installing R on Ubuntu On Mon, Feb 9, 2009 at 4:51 AM, Neil Shephard nsheph...@gmail.com wrote: The preceived difficulty of installing R under whatever flavour of GNU/Linux in this thread stems from being unfamiliar with the process of the package management of the flavour of GNU/Linux you use (and in part by the various distros not having the most recent version of R in their repositories. People who say why can't it be as easy as dowloading a self-installing binary and running that are trying to fit a round peg (their experience and understanding of how applications install in M$-windows) in a square hole (or triangular, hexagonal, or whatever depending on the distribution of GNU/Linux). This is true. However, for the most common Linux distros --Debian, Red Hat Enterprise / CentOS / Scientific Linux / Fedora, openSUSE and Ubuntu -- you can install the most recent R compiled for your distro from http://your-nearest-CRAN-mirror/bin/linux/ In addition, most of the distros have third-party repositories where you can find the latest version of R. In short, if you have an x86 or x86_64/amd64 system running almost any Linux, you can find a pre-compiled R. R is a popular package, and it's pretty easy to find even for Power PC or some of the obscure architectures. There are pro's and con's to each of the GNU/Linux flavours and its really a matter of deciding which you like/have invested time in learning. Irrespective its still simple to install R from source under GNU/Linux... 1) Download source tar-ball 2) Extract and cd to the directory 3) ./configure --prefix=/where/you/want/R/to/go (optionally setting the install path at this stage) 4) ./make 5) ./make install ...all documented in the FAQ at http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Unix_0029 Many Linux distros do *not* install the development tools by default, and which ones live in which packages varies by distro. Fedora in particular is extremely stripped when you install from the LiveCD. You have to install gcc, make and a couple of other things just to install VMware Tools, for example, when running Fedora as a VMware guest. For building R from source and installing R packages, you'll also need to install gfortran. And many libraries with external dependencies, like Rgraphviz, will require not only the package itself (graphviz) but also the C headers, which may have the name graphviz-devel on some distros and some other name on other distros. This might not be as clean as using the native package management, but does mean that you'll have the latest version installed. Neil (Addendum - I've tried several different distros, starting with RedHat 7.3, then various versions of Slackware 8 through to 9 before settling on Gentoo, all were easy to install R in). I just recently switched from Gentoo to openSUSE. Gentoo usually had the latest R source in their repository within a day or so of it coming out of the R Project release cycle. To get it, all you needed to do was put the package name in the /etc/portage/package-keywords file. And Gentoo, since it is almost all compiled from source, by nature *does* have all the development tools installed and installs all the headers when it installs packages. -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed. __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390
Re: [R] outer to vectors
Dear Patricia, Take a look at this post: http://www.nabble.com/Re:-applying-cor.test-to-a-(m,-n)-matrix---SUMMARY-to17150239.html#a17150239 The easiest way is using cor. See ?cor for details. Here is an example: set.seed(12) A-matrix(rnorm(30),ncol=3) cor(A) # [,1] [,2] [,3] # [1,] 1.000 -0.2015320 0.7235916 # [2,] -0.2015320 1.000 -0.5559593 # [3,] 0.7235916 -0.5559593 1.000 HTH, Jorge On Mon, Feb 9, 2009 at 11:44 AM, patricia garcía gonzález kurtney...@hotmail.com wrote: Hi all, Having a matrix A formed by n vectors as columns. Is there anything to calculate a determined function to all combination of vectors? For example imagine A matrix is compose by vectors a, b and c. And the function to perform is correlation, so I would like to obtain cor(a, b), cor(a, c) and cor(b, c). I we had numbers instead of vector, the function is outer, but I am not able to apply it to vectors... Thanks a lot. P. Date: Mon, 9 Feb 2009 08:37:06 -0800 From: zzn...@gmail.com To: r-help@r-project.org Subject: Re: [R] installing R on Ubuntu On Mon, Feb 9, 2009 at 4:51 AM, Neil Shephard nsheph...@gmail.com wrote: The preceived difficulty of installing R under whatever flavour of GNU/Linux in this thread stems from being unfamiliar with the process of the package management of the flavour of GNU/Linux you use (and in part by the various distros not having the most recent version of R in their repositories. People who say why can't it be as easy as dowloading a self-installing binary and running that are trying to fit a round peg (their experience and understanding of how applications install in M$-windows) in a square hole (or triangular, hexagonal, or whatever depending on the distribution of GNU/Linux). This is true. However, for the most common Linux distros --Debian, Red Hat Enterprise / CentOS / Scientific Linux / Fedora, openSUSE and Ubuntu -- you can install the most recent R compiled for your distro from http://your-nearest-CRAN-mirror/bin/linux/ In addition, most of the distros have third-party repositories where you can find the latest version of R. In short, if you have an x86 or x86_64/amd64 system running almost any Linux, you can find a pre-compiled R. R is a popular package, and it's pretty easy to find even for Power PC or some of the obscure architectures. There are pro's and con's to each of the GNU/Linux flavours and its really a matter of deciding which you like/have invested time in learning. Irrespective its still simple to install R from source under GNU/Linux... 1) Download source tar-ball 2) Extract and cd to the directory 3) ./configure --prefix=/where/you/want/R/to/go (optionally setting the install path at this stage) 4) ./make 5) ./make install ...all documented in the FAQ at http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Unix_0029 Many Linux distros do *not* install the development tools by default, and which ones live in which packages varies by distro. Fedora in particular is extremely stripped when you install from the LiveCD. You have to install gcc, make and a couple of other things just to install VMware Tools, for example, when running Fedora as a VMware guest. For building R from source and installing R packages, you'll also need to install gfortran. And many libraries with external dependencies, like Rgraphviz, will require not only the package itself (graphviz) but also the C headers, which may have the name graphviz-devel on some distros and some other name on other distros. This might not be as clean as using the native package management, but does mean that you'll have the latest version installed. Neil (Addendum - I've tried several different distros, starting with RedHat 7.3, then various versions of Slackware 8 through to 9 before settling on Gentoo, all were easy to install R in). I just recently switched from Gentoo to openSUSE. Gentoo usually had the latest R source in their repository within a day or so of it coming out of the R Project release cycle. To get it, all you needed to do was put the package name in the /etc/portage/package-keywords file. And Gentoo, since it is almost all compiled from source, by nature *does* have all the development tools installed and installs all the headers when it installs packages. -- M. Edward (Ed) Borasky I've never met a happy clam. In fact, most of them were pretty steamed. __ 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
[R] meaning of warning messages
Hi all, Read a string of data and had this message during a plot run. Warning message: closing unused connection 3 (Lines) Not sure what this means or if it should be of concern. Tnx. __ 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] Tables in legend
Thanks Jim. That was the first thing I tried. I should have mentioned that I was also trying to write the three columns of the legend using three different colors. So I want the blah column to be black, second column to be red and the third column to be blue. I would appreciate if you can share any ideas on how to do this. -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Friday, February 06, 2009 4:52 PM To: Vemuri, Aparna Cc: r-help@r-project.org Subject: Re: [R] Tables in legend This will probably do what you need: plot(1) x - 1:10 # numbers for the legend blah - LETTERS[1:5] legendData - character(5) for (i in 1:5) legendData[i] - sprintf(Blah-%s %d %d, blah[i], x[2*i - 1], x[2*i]) legend('topright', legend=legendData) On Fri, Feb 6, 2009 at 6:57 PM, Vemuri, Aparna avem...@epri.com wrote: I need to create a legend for a simple scatter plot in the following format. This is Blah1 number1 number2 This is Blah2 number3 number4 . . . This is Blah6 number11number12 I looked up these help pages and found the following solution. lStr-c(Blah1, Blah2,Blah6, number 1, number2, ...number12) legend(x=topright,lStr,ncol=3) So this creates the tabular format I am looking for. But the width of each column is matched to the width of the longest column. So the legend now looks like this: This is Blah1 number1 number2 This is Blah2 number3 number4 . . . This is Blah6 number11 number12 And thus, I have the legend occupying most part of the top half of my plot. I was wondering if there is any way to fit in the legend compactly or even better to format the width of columns 2 and 3 in the legend and remove the blank spaces between them. I have tried rounding off the number values to 3 digits with no luck. I hope this is not too ambitious to ask. Thanks in advance! Aparna __ 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. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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] meaning of warning messages
On Mon, 9 Feb 2009, Neotropical bat risk assessments wrote: Hi all, Read a string of data and had this message during a plot run. Warning message: closing unused connection 3 (Lines) Not sure what this means or if it should be of concern. It means R tidied up after you. But it may have tidied up things you dropped by mistake, hence the warning. Without a full example (see the footer of this message) we cannot tell what you (or a package you are using) did wrong. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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 equivalent of SAS Cochran-Mantel-Haenszel tests?
How about 'cmh_test' in the coin package? From the PDF: The null hypothesis of the independence of y and x is tested, block defines an optional factor for stratification. chisq_test implements Pearson’s chi-squared test, cmh_test the Cochran-Mantel-Haenzsel test and lbl_test the linear-by-linear association test for ordered data. David Freedman Michael Friendly wrote: In SAS, for a two-way (or 3-way, stratified) table, the CMH option in SAS PROC FREQ gives 3 tests that take ordinality of the factors into account, for both variables, just the column variable or neither. Is there an equivalent in R? The mantelhaen.test in stats gives something quite different (a test of conditional independence for *nominal* factors in a 3-way table). e.g. I'd like to reproduce: *-- CMH tests; proc freq data=sexfun order=data; weight count; tables husband * wife / cmh chisq nocol norow; run; The FREQ Procedure Summary Statistics for Husband by Wife Cochran-Mantel-Haenszel Statistics (Based on Table Scores) StatisticAlternative HypothesisDF Value Prob 1Nonzero Correlation1 10.01420.0016 2Row Mean Scores Differ 3 12.56810.0057 3General Association9 16.76890.0525 -- 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. -- View this message in context: http://www.nabble.com/R-equivalent-of-SAS-Cochran-Mantel-Haenszel-tests--tp21914012p21918306.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] How to create grouping in the residual plot
Dear all, I am working in a country level data. After running the regression, I would like to plot the residuals of each observation based on the group created for a particular variable. For example, one of my independent variable is Income, I would like to plot the residual based on income categories (5000, 5001-10,000, 10001-15,000 etc) with different color for each income group. Any hints or pointers will be highly appreciated. Thank you, Ram -- Ram Pandit 1449 Richland Road Apartment 3M Auburn, AL 36832 [[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] XML package- accessing nodes based on attributes
Hi, I have a rather complex xml document that I am attempting to parse based on attributes: Manifest xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; !-- eName : name of the element. eValue : value of the element. -- OutputFilePathD:\CN_data\Agilent\Results\/OutputFilePath FilesList File Characteristic Type=File eName=FileTypeId eValue=10/ Characteristic Type=File eName=FilePath eValue=D:\CN_data\Agilent\TCGA-06-0875-01A-01D-0387-02_US23502331_251469343372_S01_CGH-v4_10_Apr08.txt/ Characteristic Type =Patient eName=PatientReference eValue=TCGA-06-0875-01A/ Characteristic Type =Patient eName=SampleType eValue=TUMOR/ Characteristic Type =Patient eName=SampleMarker eValue=cy3/ Characteristic Type =Patient eName=PatientDateOfBirth eValue=080808/ Characteristic Type =Patient eName=PatientGender eValue=M/ Characteristic Type =Patient eName=PatientSampleConcentration eValue=20mg/ /File File Characteristic Type=File eName=FileTypeId eValue=10/ Characteristic Type=File eName=FilePath eValue=D:\CN_data\Agilent\TCGA-06-0875-01A-01D-0387-02_US23502331_251469343372_S02_CGH-v4_10_Apr08.txt/ Characteristic Type =Patient eName=PatientReference eValue=TCGA-06-0875-02A/ Characteristic Type =Patient eName=SampleType eValue=TUMOR/ Characteristic Type =Patient eName=SampleMarker eValue=cy3/ Characteristic Type =Patient eName=PatientDateOfBirth eValue=080808/ Characteristic Type =Patient eName=PatientGender eValue=M/ Characteristic Type =Patient eName=PatientSampleConcentration eValue=20mg/ /File File Characteristic Type=File eName=FileTypeId eValue=20/ Characteristic Type=File eName=FilePath eValue=D:\CN_data\Agilent\TCGA-06-0875-10A-01D-0387-02_US23502331_251469342195_S01_CGH-v4_10_Apr08.txt/ Characteristic Type =Patient eName=PatientReference eValue=TCGA-06-0875-10A/ Characteristic Type =Patient eName=SampleType eValue=NORMAL/ Characteristic Type =Patient eName=SampleMarker eValue=cy3/ Characteristic Type =Patient eName=PatientDateOfBirth eValue=080808/ Characteristic Type =Patient eName=PatientGender eValue=M/ Characteristic Type =Patient eName=PatientSampleConcentration eValue=20mg/ /File My requirement is to access eValues at each File node based on FileTypeId. For example: How can I get the eValue of eName=PatientReference for all Type=Patient ,where the Characteristic Type=File eName=FileTypeId eValue=10/? i.e. TCGA-06-0875-01A and TCGA-06-0875-02A For the life of me, I can not get this to work! Thanks, -Aaron [[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] How to avoid losing a sample as reference running an individual differential expression analysis (LIMMA)
Hello listmemebers, I have data from two-color microarray expression profiling experiments where 3 whole brain (WB) samples were compared to 3 Mauthner Cells (MC) in a loop design (- MC #1 - WB #1 - MC #2 - WB #2 - MC #3 - WB #3 - MC #1 -). In addition to phenotype analysis I would also like to run an individual analysis making all pair-wise comparisons. I'm using the LIMMA package in R to do this. The problem is that the contrast matrix that you have to set up requires that one of the samples be designated as a reference, but in doing so you lose the sample. My question is this, is it possible to run individual analysis with this data set without losing one as a reference point? Many thanks in advance, Dmitriy [[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] appropriate error term for AOV repeated block design
I am using AOV and I am not sure if my model structure is correct for the repeated measures. I want to verify if there is a interaction of a random factor(block) with fixed factors(veget,fruit, time,) model-aov(trackarcsin~veget*fruit*time*block +Error(block/(veget*fruit)),data=mice) Because it is repeated measures do I have to use an error term for that? here is my experimental design My experiment consists of manipulating fruits (F) and vegetation (V) to two levels each(intact (I) or removed (R) VIFR VRFI VIFI VRFR = summary(model-aov(trackarcsin~veget*fruit*time*block +Error(block/(veget*fruit)),data=mice) ) Error: block Df Sum Sq Mean Sq block 2 2804.2 1402.1 Error: block:veget Df Sum Sq Mean Sq veget1 537.66 537.66 veget:block 2 19.699.85 Error: block:fruit Df Sum Sq Mean Sq fruit1 79.417 79.417 fruit:block 2 204.688 102.344 Error: block:veget:fruit Df Sum Sq Mean Sq veget:fruit1 31.053 31.053 veget:fruit:block 2 88.472 44.236 Error: Within Df Sum Sq Mean Sq time 14 3160.61 225.76 veget:time 14 554.85 39.63 fruit:time 14 336.02 24.00 time:block 28 1306.89 46.67 veget:fruit:time 14 623.75 44.55 veget:time:block 28 584.31 20.87 fruit:time:block 28 1401.77 50.06 veget:fruit:time:block 28 810.79 28.96 -- View this message in context: http://www.nabble.com/appropriate-error-term-for-AOV-repeated-block-design-tp21918890p21918890.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] meaning of warning messages
On Mon, Feb 9, 2009 at 12:36 PM, Neotropical bat risk assessments neotropical.b...@gmail.com wrote: Read a string of data and had this message during a plot run. Warning message: closing unused connection 3 (Lines) Not sure what this means or if it should be of concern. This simply means that a file/database handle has been garbage collected because it has become inaccessible, a perfectly normal and innocuous event. For example: fff - file(/tmp) # open a file fff - NULL # it is now inaccessible through fff gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 106619 2.9 35 9.4 35 9.4 Vcells 74987 0.6 786432 6.0 353825 2.7 Warning message: closing unused connection 3 (/tmp) file(/tmp) is no longer available I don't know why R considers this a warning, or for that matter why it prints a notification at all with gcinfo(FALSE). Of course, it is possible to inadvertently make a file inaccessible, but then it is also possible to inadvertently make important data inaccessible, and of course that is not signalled. -s [[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] meaning of warning messages
Without a full example (see the footer of this message) we cannot tell what you (or a package you are using) did wrong. That's the main point. But one possibility might be that if they're using TINN-R on Windows, this warning occurs all the time as Tinn-R opens connections for sourcing data into R. Totally innocuous. But just a guess without the info as above. -- Bert Gunter Genentech __ 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] Choosing a random number between x and y
Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context: http://www.nabble.com/Choosing-a-random-number-between-x-and-y-tp21914106p21914106.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] problems with lm for nested fixed-factor Anova
Dear R users, I want to run nested fixed-factor Anova in R on different experiments. In this toy example I have 3 levels of the main factor x1 and 7 levels of the nested factor z1 x1 and continuous response variable y1. x1 [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 [38] 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 [75] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 z1 [1] 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 [38] 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 [75] 5 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 7. When I run lm on using nested design anov1=lm(c(as.vector(y1)) ~as.factor(x1)+ as.factor(x1)/as.factor(z1)) I get a warning summary(anov1) Coefficients: (14 not defined because of singularities). I get interaction between factors that should not be included because of the nested design. Why R includes them? This is becomes a problem when you apply similar concept to large datasets having, i.e. 100 and 500 main and nested factor levels - the computations become prohibitively slow? Many thanks for your help in advance! Coefficients: (14 not defined because of singularities) Estimate Std. Error t value Pr(|t|) (Intercept)-0.1759 0.3226 -0.545 0.5869 as.factor(x1)2 -0.1276 0.4473 -0.285 0.7762 as.factor(x1)3 0.6461 0.4785 1.350 0.1802 as.factor(x1)1:as.factor(z1)2 0.1049 0.4473 0.234 0.8151 as.factor(x1)2:as.factor(z1)2 NA NA NA NA as.factor(x1)3:as.factor(z1)2 NA NA NA NA as.factor(x1)1:as.factor(z1)3 NA NA NA NA as.factor(x1)2:as.factor(z1)3 1.1520 0.4473 2.575 0.0116 * as.factor(x1)3:as.factor(z1)3 NA NA NA NA as.factor(x1)1:as.factor(z1)4 NA NA NA NA as.factor(x1)2:as.factor(z1)4 NA NA NA NA as.factor(x1)3:as.factor(z1)4 NA NA NA NA as.factor(x1)1:as.factor(z1)5 NA NA NA NA as.factor(x1)2:as.factor(z1)5 NA NA NA NA as.factor(x1)3:as.factor(z1)5 -0.6841 0.4181 -1.636 0.1052 as.factor(x1)1:as.factor(z1)6 NA NA NA NA as.factor(x1)2:as.factor(z1)6 NA NA NA NA as.factor(x1)3:as.factor(z1)6 -0.6713 0.4562 -1.472 0.1445 as.factor(x1)1:as.factor(z1)7 NA NA NA NA as.factor(x1)2:as.factor(z1)7 NA NA NA NA as.factor(x1)3:as.factor(z1)7 NA NA NA NA -- Sergii Ivakhno PhD student Computational Biology Group Cancer Research UK Cambridge Research Institute Li Ka Shing Centre Robinson Way Cambridge CB2 0RE England +44 (0)1223 404293 (O) +44 (0)1223 404128 (F) http://www.compbio.group.cam.ac.uk http://www.compbio.group.cam.ac.uk/ / This communication is from Cancer Research UK. Our website is at www.cancerresearchuk.org. We are a charity registered under number 1089464 and a company limited by guarantee registered in England Wales under number 4325234. Our registered address is 61 Lincoln's Inn Fields, London WC2A 3PX. Our central telephone number is 020 7242 0200. This communication and any attachments contain information which is confidential and may also be privileged. It is for the exclusive use of the intended recipient(s). If you are not the intended recipient(s) please note that any form of disclosure, distribution, copying or use of this communication or the information in it or in any attachments is strictly prohibited and may be unlawful. If you have received this communication in error, please notify the sender and delete the email and destroy any copies of it. E-mail communications cannot be guaranteed to be secure or error free, as information could be intercepted, corrupted, amended, lost, destroyed, arrive late or incomplete, or contain viruses. We do not accept liability for any such matters or their consequences. Anyone who communicates with us by e-mail is taken to accept the risks in doing so. [[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] Next-generation sequencing data analysis with R
Hello, everyone! I have a set of proteomic data .And I do a solexa sequencing in the corresponding sample. So I get much mass sequencing data. How can I using R to integrate those two set data. I wonder if some tool or R package would help me? Thank you ! [[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] Choosing a random number between x and y
Vie wrote: Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I'm no R expert, but this should give you n uniformly distributed random numbers scaled down to the range 0..max where max 1 (and yes, I know, this makes it not-so-uniform): rrange - function(n, max) { result - runif(n) * max; result } Use it as follows: rrange(12, 0.7) # generate 12 numbers between 0 and 0.7 If you are looking for integer values from a minimum to a maximum (inclusive), this should work: irange - function(n, min,max) { result - min + trunc(runif(n) * (max - min + 1)); result } Used as follows: irange(12, 5, 20) # generate 12 integers in the range 5..20 inclusive -- View this message in context: http://www.nabble.com/Choosing-a-random-number-between-x-and-y-tp21914106p21918718.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] Choosing a random number between x and y
The runif function meets the stated criteria, if that is not good enough, then give us more detail. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of Vie Sent: Monday, February 09, 2009 7:41 AM To: r-help@r-project.org Subject: [R] Choosing a random number between x and y Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context: http://www.nabble.com/Choosing-a-random- number-between-x-and-y-tp21914106p21914106.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] Choosing a random number between x and y
See ?runif -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vie Sent: Monday, February 09, 2009 9:41 AM To: r-help@r-project.org Subject: [R] Choosing a random number between x and y Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context: http://www.nabble.com/Choosing-a-random-number-between-x-and-y -tp21914106p21914106.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] Choosing a random number between x and y
How about this: runif(1,0,0.5) [1] 0.4806179 runif(1,0,0.7) [1] 0.1789742 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vie Sent: Monday, February 09, 2009 9:41 AM To: r-help@r-project.org Subject: [R] Choosing a random number between x and y Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context: http://www.nabble.com/Choosing-a-random-number-between-x-and-y-tp2191410 6p21914106.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. -- This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. References to Merrill Lynch are references to any company in the Merrill Lynch Co., Inc. group of companies, which are wholly-owned by Bank of America Corporation. Secu! rities and Insurance Products: * Are Not FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not Insured by Any Federal Government Agency. Attachments that are part of this E-communication may have additional important disclosures and disclaimers, which you should read. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing. -- __ 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] Choosing a random number between x and y
Vie wxv579 at bham.ac.uk writes: Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. assuming you want uniform distribution ?runif These functions provide information about the uniform distribution on the interval from min to max. dunif gives the density, punif gives the distribution function qunif gives the quantile function and runif generates random deviates. 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] Choosing a random number between x and y
on 02/09/2009 08:40 AM Vie wrote: Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance If the numbers are to be uniformly distributed within the range you specify, see ?runif: runif(10, 0, 0.5) [1] 0.33273548 0.34751295 0.15387123 0.32831769 0.01863003 0.28881336 [7] 0.25578130 0.47281504 0.29631693 0.21392932 runif(10, 0, 0.7) [1] 0.52535461 0.12373738 0.40943192 0.02131712 0.32761085 0.22612708 [7] 0.40411518 0.33841189 0.02760388 0.03942751 This would be covered, for example, in An Introduction to R: http://cran.r-project.org/doc/manuals/R-intro.html#Probability-distributions HTH, Marc Schwartz __ 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] Choosing a random number between x and y
Hi Vie, Take a look at ?runif. set.seed(123) runif(1,0,0.5) [1] 0.1437888 runif(1,0,0.7) [1] 0.5518136 HTH, Jorge On Mon, Feb 9, 2009 at 9:40 AM, Vie wxv...@bham.ac.uk wrote: Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context: http://www.nabble.com/Choosing-a-random-number-between-x-and-y-tp21914106p21914106.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.
[R] Generating new variable based on values of an existing variable
Dear R Help-Listers: I have a problem that seems like it should have a simple solution, but I've spent hours on it (and searching the r-help archives) to no avail. What I'd like to do is to generate a new variable within a data frame, the values of which are dependent upon the values of an existing variable within that data frame. Assume that I have the following data: mydf-data.frame(region=c(rep(North, 5), rep(East, 5), rep(South, 5), rep(West, 5))) Assume, in addition, that I have a factor vector with four values (I actually have a factor with almost two-hundred values): element-c(earth, water, air, fire) I would like to add a new variable to the data frame (called element) such that the value of element is earth in each observation for which mydf$region==North, etc. In STATA, this was relatively easy; is there a simple way to do this in R? This is what the final result should look like: mydf region element 1 North earth 2 North earth 3 North earth 4 North earth 5 North earth 6East water 7East water 8East water 9East water 10 East water 11 South air 12 South air 13 South air 14 South air 15 South air 16 Westfire 17 Westfire 18 Westfire 19 Westfire 20 Westfire Thanks in advance, Josip __ 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] Choosing a random number between x and y
If you want to chose numbers from your range with uniform probability runif(1, 0, 0.5) See ?runif -Christos -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Vie Sent: Monday, February 09, 2009 9:41 AM To: r-help@r-project.org Subject: [R] Choosing a random number between x and y Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context: http://www.nabble.com/Choosing-a-random-number-between-x-and-y -tp21914106p21914106.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] XML package- accessing nodes based on attributes
XPath is your friend here. getNodeSet(mf, '//characterist...@type=File and @eName=FileTypeId and @eValue=10]/parent::File /characterist...@type=Patient and @eName=PatientReference]/@eValue') I have broken the XPath expression across lines to try to format it more legibly. The basic idea is to first find only the File nodes which have the required Characteristic with the specific values for the File, FileTypeId and eValue attributes. Then go back up to the parent File element and then extract the other Characteristic that you want. You can then call unlist if you want a character vector. D. Skewes,Aaron wrote: Hi, I have a rather complex xml document that I am attempting to parse based on attributes: Manifest xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; !-- eName : name of the element. eValue : value of the element. -- OutputFilePathD:\CN_data\Agilent\Results\/OutputFilePath FilesList File Characteristic Type=File eName=FileTypeId eValue=10/ Characteristic Type=File eName=FilePath eValue=D:\CN_data\Agilent\TCGA-06-0875-01A-01D-0387-02_US23502331_251469343372_S01_CGH-v4_10_Apr08.txt/ Characteristic Type =Patient eName=PatientReference eValue=TCGA-06-0875-01A/ Characteristic Type =Patient eName=SampleType eValue=TUMOR/ Characteristic Type =Patient eName=SampleMarker eValue=cy3/ Characteristic Type =Patient eName=PatientDateOfBirth eValue=080808/ Characteristic Type =Patient eName=PatientGender eValue=M/ Characteristic Type =Patient eName=PatientSampleConcentration eValue=20mg/ /File File Characteristic Type=File eName=FileTypeId eValue=10/ Characteristic Type=File eName=FilePath eValue=D:\CN_data\Agilent\TCGA-06-0875-01A-01D-0387-02_US23502331_251469343372_S02_CGH-v4_10_Apr08.txt/ Characteristic Type =Patient eName=PatientReference eValue=TCGA-06-0875-02A/ Characteristic Type =Patient eName=SampleType eValue=TUMOR/ Characteristic Type =Patient eName=SampleMarker eValue=cy3/ Characteristic Type =Patient eName=PatientDateOfBirth eValue=080808/ Characteristic Type =Patient eName=PatientGender eValue=M/ Characteristic Type =Patient eName=PatientSampleConcentration eValue=20mg/ /File File Characteristic Type=File eName=FileTypeId eValue=20/ Characteristic Type=File eName=FilePath eValue=D:\CN_data\Agilent\TCGA-06-0875-10A-01D-0387-02_US23502331_251469342195_S01_CGH-v4_10_Apr08.txt/ Characteristic Type =Patient eName=PatientReference eValue=TCGA-06-0875-10A/ Characteristic Type =Patient eName=SampleType eValue=NORMAL/ Characteristic Type =Patient eName=SampleMarker eValue=cy3/ Characteristic Type =Patient eName=PatientDateOfBirth eValue=080808/ Characteristic Type =Patient eName=PatientGender eValue=M/ Characteristic Type =Patient eName=PatientSampleConcentration eValue=20mg/ /File My requirement is to access eValues at each File node based on FileTypeId. For example: How can I get the eValue of eName=PatientReference for all Type=Patient ,where the Characteristic Type=File eName=FileTypeId eValue=10/? i.e. TCGA-06-0875-01A and TCGA-06-0875-02A For the life of me, I can not get this to work! Thanks, -Aaron [[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] How to create grouping in the residual plot
Ram Pandit pandit.ram at gmail.com writes: I am working in a country level data. After running the regression, I would like to plot the residuals of each observation based on the group created for a particular variable. For example, one of my independent variable is Income, I would like to plot the residual based on income categories (5000, 5001-10,000, 10001-15,000 etc) with different color for each income group. Any hints or pointers will be highly appreciated. (Any sample data set would also be appreciated) library(nlme) # only required for data set library(lattice) data(Orthodont) lm.or = lm(distance~age+Sex,data=Orthodont) Orthodont$res = residuals(lm.or) # in one plot xyplot(res~age,groups=Sex,data=Orthodont) # in two panels, with a bit of additional luxury xyplot(res~age|Sex,data=Orthodont,aspect=1, panel = function(x, y) { panel.grid(h=-1, v= -2) panel.xyplot(x, y,pch=16) panel.loess(x,y, span=1) }) __ 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] Choosing a random number between x and y
Hi Vie, Something like the following should be fine: ## R Start... n-1 my.min - 0 my.max - 0.7 runif(n, my.min, my.max) [1] 0.01145260 ## R end. see ?runif for details. Hope that helps a little, Tony Breyal On 9 Feb, 14:40, Vie wxv...@bham.ac.uk wrote: Hi, Ive been trying to find a function that will allow me to pull out a number between a minimum and maximum threshold. I want a random decimal number between, for example, 0 and 0.5 or 0 and 0.7. I've been searching everywhere for a function that will allow me to do this in R, but I have yet to be successful. Any help would be much appreciated. Thanks in advance -- View this message in context:http://www.nabble.com/Choosing-a-random-number-between-x-and-y-tp2191... Sent from the R help mailing list archive at Nabble.com. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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] Generating new variable based on values of an existing variable
One way to do this is through transform, assuming that there is one-to-one correspondence between regions and elements: mydf - data.frame(region=c(rep(North, 5), rep(East, 5), rep(South, 5), rep(West, 5))) elements - c(earth, water, air, fire) transform(mydf, element = factor(region, levels=c(North, East, South, West), labels=elements)) -Christos -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Josip Dasovic Sent: Monday, February 09, 2009 2:30 PM To: r-help@r-project.org Subject: [R] Generating new variable based on values of an existing variable Dear R Help-Listers: I have a problem that seems like it should have a simple solution, but I've spent hours on it (and searching the r-help archives) to no avail. What I'd like to do is to generate a new variable within a data frame, the values of which are dependent upon the values of an existing variable within that data frame. Assume that I have the following data: mydf-data.frame(region=c(rep(North, 5), rep(East, 5), rep(South, 5), rep(West, 5))) Assume, in addition, that I have a factor vector with four values (I actually have a factor with almost two-hundred values): element-c(earth, water, air, fire) I would like to add a new variable to the data frame (called element) such that the value of element is earth in each observation for which mydf$region==North, etc. In STATA, this was relatively easy; is there a simple way to do this in R? This is what the final result should look like: mydf region element 1 North earth 2 North earth 3 North earth 4 North earth 5 North earth 6East water 7East water 8East water 9East water 10 East water 11 South air 12 South air 13 South air 14 South air 15 South air 16 Westfire 17 Westfire 18 Westfire 19 Westfire 20 Westfire Thanks in advance, Josip __ 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] Generating new variable based on values of an existing variable
on 02/09/2009 01:30 PM Josip Dasovic wrote: Dear R Help-Listers: I have a problem that seems like it should have a simple solution, but I've spent hours on it (and searching the r-help archives) to no avail. What I'd like to do is to generate a new variable within a data frame, the values of which are dependent upon the values of an existing variable within that data frame. Assume that I have the following data: mydf-data.frame(region=c(rep(North, 5), rep(East, 5), rep(South, 5), rep(West, 5))) Assume, in addition, that I have a factor vector with four values (I actually have a factor with almost two-hundred values): element-c(earth, water, air, fire) I would like to add a new variable to the data frame (called element) such that the value of element is earth in each observation for which mydf$region==North, etc. In STATA, this was relatively easy; is there a simple way to do this in R? This is what the final result should look like: mydf region element 1 North earth 2 North earth 3 North earth 4 North earth 5 North earth 6East water 7East water 8East water 9East water 10 East water 11 South air 12 South air 13 South air 14 South air 15 South air 16 Westfire 17 Westfire 18 Westfire 19 Westfire 20 Westfire Thanks in advance, Josip I am going to presume that unlike your example data above, the real data may not be sequenced in unique sequential runs. Thus, a more general approach would be to set mydf$region as a factor, with the factor levels set to match 1:1 the sequence in 'elements': mydf$region - factor(mydf$region, levels = c(North, East, South, West)) element - c(earth, water, air, fire) # Set mydf$element to the value in 'element' which corresponds to the # underlying factor integer code for mydf$region mydf$element - element[as.numeric(mydf$region)] mydf region element 1 North earth 2 North earth 3 North earth 4 North earth 5 North earth 6East water 7East water 8East water 9East water 10 East water 11 South air 12 South air 13 South air 14 South air 15 South air 16 Westfire 17 Westfire 18 Westfire 19 Westfire 20 Westfire HTH, Marc Schwartz __ 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] ROracle - ORA-02005: implicit (-1) length not valid for this bind or define datatype
Hi all!! I would like to know if anyone has experienced this behaviour with ROracle package. I'm attaching information to reproduce the issue. Bug maybe? Thank you very much for your attention. Ramon. ## ## oraExecStatement BUG : RS-DBI driver: (ORA-02005: implicit (-1) length not valid for this bind or define datatype ## ## library(ROracle) Loading required package: DBI ora - dbDriver(Oracle) con - dbConnect(ora, user = u, password = , dbname = ) dafra01 - data.frame(N1=rep(c(10),10),C1=rep(c(11),10),N2=rep(c(12),10),stringsAsFactors=FALSE) ps - oraPrepareStatement(con=con, statement=insert into tmp_r (N1,C1,N2) values(:1,:2,:3), bind= c(numeric,character,numeric)) oraDescribePreparedStatement(ps) OraPreparedStatement:(24060,0,0) Statement: insert into tmp_r (N1,C1,N2) values(:1,:2,:3) Has completed? no Affected rows: -1 Rows fetched: -1 oraPreparedStatementInfo(ps) $statement [1] insert into tmp_r (N1,C1,N2) values(:1,:2,:3) $isSelect [1] 0 $rowsAffected [1] -1 $rowCount [1] -1 $completed [1] -1 $fields $fields[[1]] NULL $boundParams parameter columnNumSclass 1 1 1double 2 2 2 character 3 3 3double oraBoundParamsInfo(ps) parameter columnNumSclass 1 1 1double 2 2 2 character 3 3 3double oraExecStatement(ps=ps, data=dafra01) Error in oraExecStatement(ps = ps, data = dafra01) : RS-DBI driver: (ORA-02005: implicit (-1) length not valid for this bind or define datatype ) ## ## Oracle version and table ## ## bash-3.2$ sqlplus SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 9 10:55:45 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options SQL describe tmp_r Name Null?Type - N1 NUMBER C1 CHAR(4) N2 NUMBER SQL ## ## Operating System: Red Hat Enterprise Linux 5 ## ## bash-3.2$ uname -a Linux prod 2.6.18-92.1.22.el5 #1 SMP Fri Dec 5 09:28:22 EST 2008 x86_64 x86_64 x86_64 GNU/Linux ## ## R version ## ## # From http://cran.at.r-project.org/bin/linux/redhat/el5/x86_64/ bash-3.2$ R R version 2.8.0 (2008-10-20) 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. 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. version _ platform x86_64-redhat-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 8.0 year 2008 month 10 day20 svn rev46754 language R version.string R version 2.8.0 (2008-10-20) .Machine $double.eps [1] 2.220446e-16 $double.neg.eps [1] 1.110223e-16 $double.xmin [1] 2.225074e-308 $double.xmax [1] 1.797693e+308 $double.base [1] 2 $double.digits [1] 53 $double.rounding [1] 5 $double.guard [1] 0 $double.ulp.digits [1] -52 $double.neg.ulp.digits [1] -53 $double.exponent [1] 11 $double.min.exp [1] -1022 $double.max.exp [1] 1024 $integer.max [1] 2147483647 $sizeof.long [1] 8 $sizeof.longlong [1] 8
Re: [R] Next-generation sequencing data analysis with R
Hi Frank, Hello, everyone! I have a set of proteomic data .And I do a solexa sequencing in the corresponding sample. So I get much mass sequencing data. How can I using R to integrate those two set data. I wonder if some tool or R package would help me? You are more likely to receive a reply on the BioConductor mailing list. BioConductor is an R based platform specifically targeted at the analysis of omic data. http://www.bioconductor.org There also is a special interest group related to the BioConductor efforts in the area of these novel high-througput sequencing technologies. Their mailing list can be found at https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing HTH, Tobias __ 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 solve equation
On Mon, Feb 9, 2009 at 4:46 PM, Giovanni Petris gpet...@uark.edu wrote: As suggested by somebody else, uniroot() can be used to solve equations in one unknown variable. However, you will never get the exact x in R, only an approximate root... Best, Giovanni Date: Sat, 07 Feb 2009 02:20:10 -0800 (PST) From: oryie 43248...@qq.com Sender: r-help-boun...@r-project.org Precedence: list Hello! I want to use R to calculate the variable x which is in some eqation, give an example: 3*x-log(x)+1=0, how to solve equation to get the exact x in R? That is correct, Giovanni. But the given equation has no (real) solution. Paul __ 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 on BarPlot
Dear all As a new user of R, can someone please help me with the following I have created a programme to analyse laboratory data and one of the graphs is a bar plot of 'Z' scores. On the bar plot I am using the following line to plot some results barplot (zb[,c(ZBW)], ylim = c(-6,6), names.arg=zb[,c(LabNo)],xlab=Lab Code Number, cex.names = .5 , axis.lty=1 , main = Total Coliform ) What I would like to do is move the xlab parameter to sit on top or on each bar and not on the x-axis at y=0. Any help would be appreciated. Thanks Steve [[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] How to plot multiple graphs each with multiple y variables
I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow. The first plot should contain data from D1-D4, the second should contain D5-D8. I can plot these separately using the code, par(mfrow=c(1,1)) plot(c(0.01,1),c(0,100),type=n, xlab=D, ylab=% R, log=x) points(D1$L0,D1$K1_R1,lwd=2, col=blue, ) points(D2$L0,D2$K1_R2,lwd=2, col=red, ) points(D3$L0,D3$K1_Rt3,lwd=2, col=orange, ) points(D4$L0,D4$K1_R4,lwd=2, col=black, ) or par(mfrow=c(1,1)) plot(c(0.01,1),c(0,100),type=n, xlab=D, ylab=% R, log=x) points(D5$L0,D1$K2_R1,lwd=2, col=blue, ) points(D6$L0,D2$K2_R2,lwd=2, col=red, ) points(D7$L0,D3$K2_Rt3,lwd=2, col=orange, ) points(D8$L0,D4$K2_R4,lwd=2, col=black, ) but how can I plot them together? Thanks in advance for your help, I appreciate any help you can give. [[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] percentage of variance explained by factors
Hello! I've run a simple linear model: result-lm(DV~A+B+C,data=Data) My Data$A,Data$B, and Data$C are factors. So, lm automatically recoded them into dummy variables. I have all the results I need but one. Question: Where could I see the variance explained by all A dummy variables together, then all B dummy variables together, and all C dummy variables together - when other predictors are present (in other words, the sum of squared semi-partial correlations for all A dummy variables, B dummy variables, and C dummy variables)? Or is it just not possible with lm? Thank you very much! -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.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 on BarPlot
on 02/09/2009 03:21 PM Steve Sidney wrote: Dear all As a new user of R, can someone please help me with the following I have created a programme to analyse laboratory data and one of the graphs is a bar plot of 'Z' scores. On the bar plot I am using the following line to plot some results barplot (zb[,c(ZBW)], ylim = c(-6,6), names.arg=zb[,c(LabNo)],xlab=Lab Code Number, cex.names = .5 , axis.lty=1 , main = Total Coliform ) What I would like to do is move the xlab parameter to sit on top or on each bar and not on the x-axis at y=0. Any help would be appreciated. If the 'Z' scores are the typical standard deviation based continuous Z scores, rather than a barplot, I would recommend a dotchart or point based plot. Barplots are best suited for count/frequency based data. See ?dotchart. With respect to the barplot, the key piece of information to know is that barplot() returns the bar midpoints, which you need to know for subsequent text placement. This is described in ?barplot. Something like this should get you there: # For reproducibility set.seed(1) # Generate a sample of LETTERS L - sample(LETTERS[1:5], 100, replace = TRUE) # Create a frequency table TL - table(L) TL L A B C D E 13 25 19 26 17 # Create the barplot, set ylim to make room for the text # set names.arg so that nothing appears below the x axis mp - barplot(TL, ylim = c(0, 30), names.arg = NA) # What's in mp? mp [,1] [1,] 0.7 [2,] 1.9 [3,] 3.1 [4,] 4.3 [5,] 5.5 # Now draw the text at x = mp; y = TL positions. # Set 'pos' to move the values above the bars text(mp, TL, labels = names(TL), pos = 3) # If you wanted the counts above the bars instead of the labels: text(mp, TL, labels = TL, pos = 3) HTH, Marc Schwartz __ 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 plot multiple graphs each with multiple y variables
Try something like this where we use the built in data frame anscombe: opar - par(mfrow = c(1, 2), no.readonly = TRUE) matplot(1:11, anscombe[1:4], pch = 1:4, col = 1:4, log = x, ylab = Y) matplot(1:11, anscombe[5:8], pch = 1:4, col = 1:4, log = x, ylab = Y) par(opar) On Mon, Feb 9, 2009 at 4:43 PM, gina patel ginapatel1...@yahoo.com wrote: I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow. The first plot should contain data from D1-D4, the second should contain D5-D8. I can plot these separately using the code, par(mfrow=c(1,1)) plot(c(0.01,1),c(0,100),type=n, xlab=D, ylab=% R, log=x) points(D1$L0,D1$K1_R1,lwd=2, col=blue, ) points(D2$L0,D2$K1_R2,lwd=2, col=red, ) points(D3$L0,D3$K1_Rt3,lwd=2, col=orange, ) points(D4$L0,D4$K1_R4,lwd=2, col=black, ) or par(mfrow=c(1,1)) plot(c(0.01,1),c(0,100),type=n, xlab=D, ylab=% R, log=x) points(D5$L0,D1$K2_R1,lwd=2, col=blue, ) points(D6$L0,D2$K2_R2,lwd=2, col=red, ) points(D7$L0,D3$K2_Rt3,lwd=2, col=orange, ) points(D8$L0,D4$K2_R4,lwd=2, col=black, ) but how can I plot them together? Thanks in advance for your help, I appreciate any help you can give. [[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] How to plot multiple graphs each with multiple y variables
Kia ora Gina If I understand you correctly, you need to specify mfrow argument as c(1,2) and then make your two calls to plot(). HTH ... Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of gina patel Sent: Tuesday, 10 February 2009 10:43 a.m. To: r-help@r-project.org Subject: [R] How to plot multiple graphs each with multiple y variables I am new to R and have a problem that I haven't been able to find the answer to in the guides or online. I have multiple datasets, D1, D2, D3, D4, D5, D6, D7 and D8, and I would like to produce two plots side by side using mfrow. The first plot should contain data from D1-D4, the second should contain D5-D8. I can plot these separately using the code, par(mfrow=c(1,1)) plot(c(0.01,1),c(0,100),type=n, xlab=D, ylab=% R, log=x) points(D1$L0,D1$K1_R1,lwd=2, col=blue, ) points(D2$L0,D2$K1_R2,lwd=2, col=red, ) points(D3$L0,D3$K1_Rt3,lwd=2, col=orange, ) points(D4$L0,D4$K1_R4,lwd=2, col=black, ) or par(mfrow=c(1,1)) plot(c(0.01,1),c(0,100),type=n, xlab=D, ylab=% R, log=x) points(D5$L0,D1$K2_R1,lwd=2, col=blue, ) points(D6$L0,D2$K2_R2,lwd=2, col=red, ) points(D7$L0,D3$K2_Rt3,lwd=2, col=orange, ) points(D8$L0,D4$K2_R4,lwd=2, col=black, ) but how can I plot them together? Thanks in advance for your help, I appreciate any help you can give. [[alternative HTML version deleted]] The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ 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] pause in function execution
I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute? __ 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] Dataframes: conditional calculations per row .
Dear Sirs: I've been working with several variables in a dataframe that serve as part of a calculation that I need to perform in a different way depending on its value. Let me explain: The main dataframe is called llmcc llmcc : 'data.frame': 283 obs. of 11 variables: $ Area : num 308.8 105.6 51.4 51.4 52.9 ... $ mFondo : num 30.1 10 10.2 10.2 40.4 ... $ mFachada : num 22.95 6.7 4.72 4.72 4.72 ... $ Marca: Factor w/ 132 levels AA_Movilnet,..: 11 32 82 82 32 32 32 32 32 32 ... $ Clase: int 8 4 1 1 1 1 1 1 12 1 ... $ Categoria: int 2 6 6 6 1 1 1 1 1 1 ... $ Phi : num 0.128 0.147 0.217 0.217 0.887 ... $ Rf : num 0.119 0.102 0.147 0.147 0.143 ... $ OldA : num 0.737 0.258 0.375 0.375 0.385 ... $ OldCondo : num 4436 1555 2260 2260 2318 ... $ NewA_Jon : num 1.069 0.368 0.256 0.256 0.264 ... I perform an initial operation using the original variables plus one numeric (Abase) that is external and has the same number of rows than the dataframe: alitemp - ((Abase/llmcc$Clase)*PClase)+(((1/llmcc $Categoria)*Abase)*PCategoria)+((Abase*llmcc$Phi)*PPhi)+((Abase*llmcc $Rf)*PRf) So, after I obtain the results of this calculation, I append the series by creating an additional column within the original dataframe: l lmcc$Alitmp - alitemp Problem is: I need to calculate a new column using a formula that has different structure depending on the values of llmcc$Clase, thus: for any given row of llmcc where llmcc$Clase is = 10 i would have to perform some operations with other values in the same row that are, by definition, different than the ones I would need in case of lmcc$Clase is 10. I've managed to break down the original dataframe by using subsets, and then performing the calculations, but then it is complicated to put the results in the same order of the original dataframe. I understand the workings of the control structures available in R but after reading the docs and help files, I can´t figure how to perform a conditional calculation row by row that checks first the values of a given column and then applies the corresponding operation to another column, so it outputs a series in the same exact order as the dataframe. Any light that you might share with me over this will be highly appreciated. Thanks in advance. Guillermo. Nunca le preguntes a un peluquero si necesitas un corte de pelo. Ley de Murray. -- Jesús Guillermo Andrade (Abg.) Gerente de Litigios y Corporativo. EDM. AC. API. Andrade Moreno S.C. (http://amlegal.wordpress.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.
[R] running totals in a list
very simple question I am sure sorry: for a list; test -c(1,2,3) how do I total them up please to return the result 1,3,6 Regards Glenn [[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] running totals in a list
First of all, this is not a list, this is a vector. Second, see ?cumsum. Best, Gabor On Mon, Feb 9, 2009 at 11:13 PM, glenn g1enn.robe...@btinternet.com wrote: very simple question I am sure sorry: for a list; test -c(1,2,3) how do I total them up please to return the result 1,3,6 Regards Glenn [[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. -- Gabor Csardi gabor.csa...@unil.ch 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] pause in function execution
I am not too sure what your question is, but try ?debug or take a look at http://www.ats.ucla.edu/stat/r/library/R-debug-tools.pdf On Feb 10, 9:07 am, Fuchs Ira irafu...@gmail.com wrote: I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute? __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://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] pause in function execution
On 09/02/2009 5:07 PM, Fuchs Ira wrote: I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute? Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. 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] cwhmisc package requests update all the time!
Dear Christian, Every single time check update package, “cwhmisc” always requests updating. I’m aware that the package was latest updated in CRAN on 20Nov2008. Is there anything wrong with my R library or somethingelse? I use R 2.8.1 on Window XP service pack 2 Regards Nguyen Garvan Institute of Medical Research Sydney, Australia __ 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] summary statistics
Hi all, I'm wondering if there is a function that can return summary statistics: N=total number of observation, # missing, mean, median, range, standard deviation. As I know, summary() returns some of info I've mentioned above. Thanks, SY [[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] pause in function execution
Yes, Windows has that in the Misc menu, but I don't see a way to do this on the Mac. On Feb 9, 2009, at 5:51 PM, Duncan Murdoch wrote: On 09/02/2009 5:07 PM, Fuchs Ira wrote: I would like to have a function which gets data, does a calculation and prints a result and then waits some number of seconds and repeats. If I use Sys.sleep, the execution is pausing but the function output is buffered so that it all comes out when the function terminates. How can I get output while the function continues to execute? Turn off buffering. In Windows, this is a menu item. Presumably it's possible on whatever platform you're using. 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] Working with RDF
Dear list, I will be working with RDF in the future, and was wondering if there's anyone else in this list doing this. Any libraries/resources to check? Thanks, -Jose -- Jose Quesada, PhD. Max Planck Institute, Human Development, Berlin http://www.josequesada.name/ __ 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] twitter useRs?
I wonder if there are any useRs sharing day-to-day realizations/tricks on twitter... Seems like a good place for those things that are good findings, but one is too lazy to blog about them... -- Jose Quesada, PhD. Max Planck Institute, Human Development, Berlin http://www.josequesada.name/ __ 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] Inverse Gaussian dist in a GEE model
For a simulation study, I need to fit a GEE with a IG distribution and using a log link function. As far as I know, there are two GEE packages available ('gee' and 'geepack') but none of them supports IG. I've also tried using family=quasi(log,mu^3) (without luck!).' Any guidance is highly appreciated Cheers, René __ New MSc Program in Aquatic Science and Technology The new MSc program offers a unique combination of biology, mathematics and technology and addresses global challenges in climate, environment and food resources. The program starts in September 2009 and is being developed collaboratively by the Technical University of Denmark and University of Copenhagen. Further information from http://aquascience.dtu.dk __ 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.