Re: [R] What is parameter "display" (windows/grDevices)
On Tue, 3 Jul 2007, Dieter Menne wrote: > In the docs of window/grDevices: Do you mean 'windows' (sic) in package 'grDevices'? > >> All these devices are implemented as windows devices, the _display_ > parameter selects which is actually used.>> > > What is the "display" parameter? The second argument to the .External call to "devga". Take a closer look at the R code to see what the comment is talking about. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to use mle with a defined function
Hi all, I am trying to use mle() to find a self-defined function. Here is my function: test <- function(a=0.1, b=0.1, c=0.001, e=0.2){ # omega is the known covariance matrix, Y is the response vector, X is the explanatory matrix odet = unlist(determinant(omega))[1] # do cholesky decomposition C = chol(omega) # transform data U = t(C)%*%Y WW=t(C)%*%X beta = lm(U~W)$coef Z=Y-X%*%beta V=solve(t(C), Z) 0.5*odet + 0.5*(t(V)%*%V) } and I am trying to call mle() to calculate the maximum likelihood estimates for function (0.5*odet+0.5*(t(V)%*%V)) by result = mle(test, method="Nelder-Mead") But I get the following error message: Error in optim(start, f, method = method, hessian = TRUE, ...) : (list) object cannot be coerced to 'double' I am pretty sure that the matrices, parameters etc are numerical before importing to the function. But why I still get such error message? Could anybody give some help on this? thanks a lot. Lin -- View this message in context: http://www.nabble.com/how-to-use-mle-with-a-defined-function-tf4015002.html#a11402268 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Plotting very skewed data in barplot
Dear R'ers, I would like to use barplot or a similar function to plot data demonstrating the distribution of the length of a kind of conservation in about 25000 DNA sequences. My data look like this: #Total sequences: 23873 0 19936 1 218 2 391 3 477 4 360 5 431 6 294 7 215 8 320 9 209 10 160 (.) 99 0 100 1 101 0 102 0 103 1 104 0 105 0 106 0 107 0 108 0 109 1 Therefore, I would like to show the column representing 0 (with 19936 sequences) "cut" so it doesn't dominate the rest of the plot. Also, starting from about 10 sequences, I would like to group the rest of the sequences into groups of 5 each (for instance, 10-15, 16-20, 21-25 etc). I have looked extensively in the help pages and in some online fora, but have not found an answer to this question. I would greatly appreciate any tips. Thanks, Peter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] select row
Hi all, I have a little problem selecting some rows from a data.frame. I'd like to select the rows where a determinated column take a partivolar value. For example: tab id x y 124-2005 1621814 4834991 224-2005 1621856 4834907 324-2005 1621763 4834956 4 25-2006 1622330 4835189 5 25-2006 1622533 4834834 6 25-2006 1622535 4834909 7 25-2006 1622543 4834803 8 28-2005 1622798 4835043 9 28-2005 1622299 4835129 I'd like to select the row where id=25-2006 I searched on the search of the R site but I did'nt find anything of simple. Can someone help me? Thank you very much Leonardo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing R packages in OpenBSD
Hello. It's been quite a while since using OpenBSD (and no OpenBSD here for me to check this out), but I do remember having to reset some of the path entries. Can you check the directory settings in the main R script and see if that's where the "fake-..." is coming from? This looks like a setting for the OpenBSD package creation that didn't get changed after package installation. Hope this helps, Jon -Original Message- From: [EMAIL PROTECTED] on behalf of Bruce Sent: Mon 7/2/2007 5:19 PM To: r-help@stat.math.ethz.ch Subject: [R] Problem installing R packages in OpenBSD OS: OpenBSD version 4.1 i386 R version 2.4.1 (2006-12-18) installed as a binary package $ ls mapproj_1.1-7.1.tar.gz maps_2.0-36.tar.gz $ sudo R CMD INSTALL mapproj_1.1-7.1.tar.gz /usr/local/lib/R/bin/INSTALL[118]: .: /usr/obj/i386/R-2.4.1/fake-i386/usr/local/lib/R/share/sh/dcf.sh: not found I get the same error message from the R command prompt using install.packages("mapproj", dep=TRUE) Questions regarding /usr/obj/i386/R-2.4.1/fake-i386: o Where did this path come from? o Is there a conflict between OpenBSD ports and R packages? o Is OpenBSD ports trying to do the package install? If so, how do I stop it? Please note that I have installed R packages successfully on Linux, Windows XP and FreeBSD. Background information --- Environment variables: $ echo $R_HOME /usr/local/lib/R $ echo $R_LIBS /usr/local/lib/R/library R install: $ pwd /usr/local/lib/R/share/sh $ ls -l total 16 -r--r--r-- 1 root bin 392 Mar 9 00:57 dcf.sh -r--r--r-- 1 root bin27 Mar 9 00:57 echo.sh -r--r--r-- 1 root bin 1506 Mar 9 00:57 help-links.sh -r--r--r-- 1 root bin 825 Mar 9 00:57 help-print.sh Thanks __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] select row
Assuming that id is a character. tab[tab$id == "25-2006", ] Cheers, 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 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney > -Oorspronkelijk bericht- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Namens Leonardo Lami > Verzonden: dinsdag 3 juli 2007 11:34 > Aan: r-help@stat.math.ethz.ch > Onderwerp: [R] select row > > Hi all, > I have a little problem selecting some rows from a data.frame. > I'd like to select the rows where a determinated column take > a partivolar value. > > For example: > tab > id x y > 124-2005 1621814 4834991 > 224-2005 1621856 4834907 > 324-2005 1621763 4834956 > 4 25-2006 1622330 4835189 > 5 25-2006 1622533 4834834 > 6 25-2006 1622535 4834909 > 7 25-2006 1622543 4834803 > 8 28-2005 1622798 4835043 > 9 28-2005 1622299 4835129 > > I'd like to select the row where id=25-2006 > > I searched on the search of the R site but I did'nt find > anything of simple. > Can someone help me? > > Thank you very much > Leonardo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] possible bug in ggplot2 v0.5.2???
Dear R-Users, I recently gave a try to the nice package ggplot2. Everything went well until I tried to add a smoother (using lm method for instance). On the graphic device the regression line is displayed but not confidence intervals as it should be (at least on ggplot website). I tried to do the job on both MS winXP and Linux i586: same result. Did anyone encountered this problem? Did I miss something? My R version is 2.4.1. Thanks, Stéphane. -- == Stephane CRUVEILLER Ph. D. Genoscope - Centre National de Sequencage Atelier de Genomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 EMails: [EMAIL PROTECTED] ,[EMAIL PROTECTED] === __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] select row
?which Use it to find the rows and then extract the rows selection <- mydata[which(mydata$id=="25-2006"), ] should work. --- Leonardo Lami <[EMAIL PROTECTED]> wrote: > Hi all, > I have a little problem selecting some rows from a > data.frame. > I'd like to select the rows where a determinated > column take a > partivolar value. > > For example: > tab > id x y > 124-2005 1621814 4834991 > 224-2005 1621856 4834907 > 324-2005 1621763 4834956 > 4 25-2006 1622330 4835189 > 5 25-2006 1622533 4834834 > 6 25-2006 1622535 4834909 > 7 25-2006 1622543 4834803 > 8 28-2005 1622798 4835043 > 9 28-2005 1622299 4835129 > > I'd like to select the row where id=25-2006 > > I searched on the search of the R site but I did'nt > find anything of simple. > Can someone help me? > > Thank you very much > Leonardo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] select row
Thanks all of you for the help! > >> Hi all, >> I have a little problem selecting some rows from a >> data.frame. >> I'd like to select the rows where a determinated >> column take a >> partivolar value. >> >> For example: >> tab >> id x y >> 124-2005 1621814 4834991 >> 224-2005 1621856 4834907 >> 324-2005 1621763 4834956 >> 4 25-2006 1622330 4835189 >> 5 25-2006 1622533 4834834 >> 6 25-2006 1622535 4834909 >> 7 25-2006 1622543 4834803 >> 8 28-2005 1622798 4835043 >> 9 28-2005 1622299 4835129 >> >> I'd like to select the row where id=25-2006 >> >> I searched on the search of the R site but I did'nt >> find anything of simple. >> Can someone help me? >> >> Thank you very much >> Leonardo >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, >> reproducible code. >> >> > > > > Get a sneak peak at messages with a handy reading pane with All new > Yahoo! Mail: http://mrd.mail.yahoo.com/try_beta?.intl=ca > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] possible bug in ggplot2 v0.5.2???
Hi Stephane, The problem is that the windows graphics device doesn't support transparent colours. You can get around this in two ways: * export to a device that does support transparency (eg. pdf) * use a solid fill colour : + stat_smooth(method="lm", fill="grey50") Hadley On 7/3/07, Stephane Cruveiller <[EMAIL PROTECTED]> wrote: > Dear R-Users, > > I recently gave a try to the nice package ggplot2. Everything went > well until I tried to add a smoother (using lm method for instance). > On the graphic device the regression line is displayed but not confidence > intervals as it should be (at least on ggplot website). I tried to do > the job on > both MS winXP and Linux i586: same result. Did anyone encountered this > problem? Did I miss something? > > > My R version is 2.4.1. > > > > Thanks, > > Stéphane. > > > -- > == > Stephane CRUVEILLER Ph. D. > Genoscope - Centre National de Sequencage > Atelier de Genomique Comparative > 2, Rue Gaston Cremieux CP 5706 > 91057 Evry Cedex - France > Phone: +33 (0)1 60 87 84 58 > Fax: +33 (0)1 60 87 25 14 > EMails: [EMAIL PROTECTED] ,[EMAIL PROTECTED] > === > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Exponentially Weighted Moving Average
Hi, I have got a series of data "x" and some parameter "a", and I would like to take some Exponentially Weighted Moving Average to the data in the following fomula, and obtain the return series y y1=a^265*x[2]+a^264*x[3]+a^263*x[4]+...+a^0*x[267] y2=a^264*x[4]+a^263*x[5]+a^263*x[6]+...+a^0*x[268] y265=a^1*x[530]+a^0*x[531] y266=a^0*x[532] Could anyone give me some advice how can I achieve this? Many thanks -- View this message in context: http://www.nabble.com/Exponentially-Weighted-Moving-Average-tf4017572.html#a11409874 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting very skewed data in barplot
Dr. med. Peter Robinson wrote: > Dear R'ers, > > I would like to use barplot or a similar function to plot data > demonstrating the distribution of the length of a kind of conservation in > about 25000 DNA sequences. My data look like this: > ... > > Therefore, I would like to show the column representing 0 (with 19936 > sequences) "cut" so it doesn't dominate the rest of the plot. Also, > starting from about 10 sequences, I would like to group the rest of the > sequences into groups of 5 each (for instance, 10-15, 16-20, 21-25 etc). > Hi Peter, Have a look at gap.barplot in the plotrix package. I would suggest something like this: gap.barplot(y,c(500,19800),main="Skewed distribution", yaxlab=c(200,400,19900),ytics=c(200,400,19900)) where y is the right column of your data. Jim __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] The R Book by M. J. Crawley
Hello all- I would appreciate any guidance that can be provided. I am new to R and am using it exclusively in a statistics program I am undertaking that mainly references Minitab. My focus is on data modeling and further more multivariate data analysis as much of my work in involves chemical measurements from custom sensors using all sorts of transduction methods. I am looking for a reference that has sound statistical foundations with relevant R commands as well as multivariate support. I saw the new book, "The R Book", by Michael J. Crawley and wanted to know what R users thoughts of it. Thanks in advance, Matt [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing R packages in OpenBSD
Thank you both for your responses. I am now able to install R packages. The front-end R scripts were changed at /usr/local/bin and /usr/local/lib/R/bin as follows: From: R_HOME_DIR=/usr/obj/i386/R-2.4.1/fake-i386/usr/local/lib/R R_SHARE_DIR=/usr/obj/i386/R-2.4.1/fake-i386/usr/local/lib/R/share export R_SHARE_DIR R_INCLUDE_DIR=/usr/obj/i386/R-2.4.1/fake-i386/usr/local/lib/R/include export R_INCLUDE_DIR R_DOC_DIR=/usr/obj/i386/R-2.4.1/fake-i386/usr/local/lib/R/doc export R_DOC_DIR To: R_HOME_DIR=/usr/local/lib/R R_SHARE_DIR=/usr/local/lib/R/share export R_SHARE_DIR R_INCLUDE_DIR=/usr/local/lib/R/include export R_INCLUDE_DIR R_DOC_DIR=/usr/local/lib/R/doc export R_DOC_DIR The R_HOME environment variable has been removed from my .profile and /etc/profile. Bruce On Tuesday 03 July 2007 03:36:38 am you wrote: > Hello. > > It's been quite a while since using OpenBSD (and no OpenBSD here for me to > check this out), but I do remember having to reset some of the path > entries. Can you check the directory settings in the main R script and see > if that's where the "fake-..." is coming from? This looks like a setting > for the OpenBSD package creation that didn't get changed after package > installation. > > Hope this helps, > > Jon > > > -Original Message- > From: [EMAIL PROTECTED] on behalf of Bruce > Sent: Mon 7/2/2007 5:19 PM > To: r-help@stat.math.ethz.ch > Subject: [R] Problem installing R packages in OpenBSD > > OS: OpenBSD version 4.1 i386 > R version 2.4.1 (2006-12-18) installed as a binary package > > $ ls > mapproj_1.1-7.1.tar.gz maps_2.0-36.tar.gz > > $ sudo R CMD INSTALL mapproj_1.1-7.1.tar.gz > > /usr/local/lib/R/bin/INSTALL[118]: > .: /usr/obj/i386/R-2.4.1/fake-i386/usr/local/lib/R/share/sh/dcf.sh: not > found > > I get the same error message from the R command prompt using > install.packages("mapproj", dep=TRUE) > > Questions regarding /usr/obj/i386/R-2.4.1/fake-i386: > o Where did this path come from? > o Is there a conflict between OpenBSD ports and R packages? > o Is OpenBSD ports trying to do the package install? If so, how do I stop > it? > > Please note that I have installed R packages successfully on Linux, Windows > XP > and FreeBSD. > > Background information > --- > Environment variables: > $ echo $R_HOME > /usr/local/lib/R > $ echo $R_LIBS > /usr/local/lib/R/library > > R install: > $ pwd > /usr/local/lib/R/share/sh > $ ls -l > total 16 > -r--r--r-- 1 root bin 392 Mar 9 00:57 dcf.sh > -r--r--r-- 1 root bin27 Mar 9 00:57 echo.sh > -r--r--r-- 1 root bin 1506 Mar 9 00:57 help-links.sh > -r--r--r-- 1 root bin 825 Mar 9 00:57 help-print.sh > > Thanks > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, minimal, > self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] The R Book by M. J. Crawley
Pietrzykowski, Matthew (GE, Research) wrote: > Hello all- > > I would appreciate any guidance that can be provided. I am new to R and > am > using it exclusively in a statistics program I am undertaking that > mainly references > Minitab. My focus is on data modeling and further more multivariate > data analysis > as much of my work in involves chemical measurements from custom sensors > using > all sorts of transduction methods. I am looking for a reference that > has sound statistical > foundations with relevant R commands as well as multivariate support. I > saw the new book, > "The R Book", by Michael J. Crawley and wanted to know what R users > thoughts of it. The author seems to be an expert in (almost?) all available statistical programming languages and able to write almost 1000 pages about these languages. He also seems to be a perfect R programmer, since the title is "The R book". Uwe Ligges > Thanks in advance, > > Matt > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generating correlated Bernoulli random variables
> > > Hi all, > > I was wondering how to generate samples for two RVs X1 and X2. > > > > X1 ~ Bernoulli (p1) > > X2 ~ Bernoulli (p2) > > > > Also, X1 and X2 are correlated with correlation \rho. > You can use the rmvbin() function in the bindata package, e.g., require(bindata) n=10 p1=0.5 p2=0.3 rho=0.2 rmvbin(n, c(p1,p2), bincorr=(1-rho)*diag(2)+rho) ?rmvbin However, as pointed out before, rho is bounded below and above by some function of the marginal probabilities. (Try above code with rho=0.9) You may want to use the odds ratio (which is unrestricted) to specify the association between the two binary variables and then convert this odds ratio, for given marginal probabilities p1 and p2, into a (valid) correlation rho to be used in rmvbin(). Here is some ad hoc code to do that: bincorr <- function(OR, p1, p2) {#from odds ratio to binary correlation if (OR==1) p11=p2-p2+p1*p2 else { p11_1=p2-(1/2/(1-OR)*(1-p1+OR*p1+p2-OR*p2- sqrt((-1+p1-OR*p1-p2+OR*p2)^2-4*(1-OR)*(p2-p1*p2 p11_2=p2-(1/2/(1-OR)*(1-p1+OR*p1+p2-OR*p2- sqrt((-1+p1-OR*p1-p2+OR*p2)^2)-4*(1-OR)*(p2-p1*p2))) if (p11_1>0 && p11_1<=p1 && p11_1https://stat.ethz.ch/mailman/listinfo/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] Exponentially Weighted Moving Average
You could use rollFun from fMultivar package. You need to define your EWMA function separately. (Usually the EWMA moves along with a constant window size, though ) David L. Reiner Rho Trading Securities, LLC 550 W. Jackson Blvd #1000 Chicago, IL 60661-5704 312-244-4610 direct 312-244-4500 main 312-244-4501 fax -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of livia Sent: Tuesday, July 03, 2007 5:51 AM To: r-help@stat.math.ethz.ch Subject: [R] Exponentially Weighted Moving Average Hi, I have got a series of data "x" and some parameter "a", and I would like to take some Exponentially Weighted Moving Average to the data in the following fomula, and obtain the return series y y1=a^265*x[2]+a^264*x[3]+a^263*x[4]+...+a^0*x[267] y2=a^264*x[4]+a^263*x[5]+a^263*x[6]+...+a^0*x[268] y265=a^1*x[530]+a^0*x[531] y266=a^0*x[532] Could anyone give me some advice how can I achieve this? Many thanks -- View this message in context: http://www.nabble.com/Exponentially-Weighted-Moving-Average-tf4017572.ht ml#a11409874 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop causes syntax error in print()
On 7/3/2007 1:59 AM, Ivan Baxter wrote: > I am having trouble printing a table out to the GUI display when the > table is created and printed within a loop. > > I get a "Error: syntax error message" > > If I comment out the print statement, the loop runs fine and I can print > out the last iteration of the table. You should simplify your loop until it's something you can post for us to try. Chances are you'll notice the error when you do that, but if not, someone else will be able to tell you what's going on. Without a reproducible example, it's more or less hopeless. Duncan Murdoch > > ...[multiple loops and calculations ending with.]... > > + print(paste(mutType,"sim",sim,"hmm",hmm)) > + # print(acctab[,10:15]) > + > + nummod <- nummod +1 > + } #end hmmMats loop > + } #end tmats loop > + } #end mut type loop > [1] "dup sim Imod hmm Jmod" > > > print(acctab[,10:15]) > hitrate falsepos multrate avghit avgmiss avgfalsepos > 1 0.0001NaN NaN 2 NA > 2 1.0000 0.5.33 NaN NA > 3 0.000 NaNNaN NaN 9 NA > 4 0.7780 0. 15.571429 11 NA > 5 1.0000 0. 24.08 NaN NA > 6 1.0000 0.07692308 64.538462 NaN NA > 7 1.0000 0.39207048 1088.454846 NaN NA > > you can see that > a) the print statement above it works > b) the print command works with this table > > but if I uncomment it and try to run the loops again. > > + print(paste(mutType,"sim",sim,"hmm",hmm)) > print(acctab[,10:15]) > Error: syntax error > > > > > > nummod <- nummod +1 > > } #end hmmMats loop > Error: syntax error > > } #end tmats loop > Error: syntax error > > } #end mut type loop > Error: syntax error > > > I have tried print.data.frame, but that doesn't work either > > > Any suggestions would be appreciated (session info below) > > > Ivan > > > > sessionInfo() > R version 2.5.1 (2007-06-27) > i386-apple-darwin8.9.1 > > locale: > C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" > "methods" "base" > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] regexpr
using lapply is so great. That help me a lot. thanks. Stephen Tucker wrote: > > I think you are looking for paste(). > > And you can replace your for loop with lapply(), which will apply regexpr > to > every element of 'mylist' (as the first argument, which is 'pattern'). > 'text' > can be a vector also: > > mylist <- c("MN","NY","FL") > lapply(paste(mylist,"$",sep=""),regexpr,text="Those from MN:") > > > > --- runner <[EMAIL PROTECTED]> wrote: > >> >> Hi, >> >> I 'd like to match each member of a list to a target string, e.g. >> -- >> mylist=c("MN","NY","FL") >> g=regexpr(mylist[1], "Those from MN:") >> if (g>0) >> { >> "On list" >> } >> -- >> My question is: >> >> How to add an end-of-string symbol '$' to the to-match string? so that >> 'M' >> won't match. >> >> Of course, "MN$" will work, but i want to use it in a loop; "mylist[i]" >> is >> what i need. I tried "mylist[1]$", but didn't work. So why it doesn't >> extrapolate? How to do it? >> >> Thanks a lot! >> -- >> View this message in context: >> http://www.nabble.com/regexpr-tf4000743.html#a11363041 >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> R-help@stat.math.ethz.ch mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > > > Bored stiff? Loosen up... > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/regexpr-tf4000743.html#a11412603 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] EWMA procedure to forecast variance
Hello, I would like to use the Exponential Weighted Moving Average procedure to get the variance. Is there any R function for doing this? Many thanks. -- View this message in context: http://www.nabble.com/EWMA-procedure-to-forecast-variance-tf4018317.html#a11412324 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MatchIt package on Ubuntu 7.04 (Feisty Fawn)
On 2 July 2007 at 23:47, Daniel Nordlund wrote: | I tried to install the MatchIt package on Ubuntu 7.04. How? Via 'sudo apt-get install r-cran-matchit', or using R? | When loading required dependencies I got the following error message: | | Error in dyn.load(x, as.logical(local), as.logical(now)) : | unable to load shared library | '/usr/local/lib/R/site-library/optmatch/libs/optmatch.so': /usr/local, so you did this using via 'R CMD INSTALL ' or from inside R. Consider removing this directory and install the Ubuntu-supplied package. Also, you didn't mention whether this is an older install of matchit, or whether you just did it. | /usr/local/lib/R/site-library/optmatch/libs/optmatch.so: cannot map zero-fill pages: Cannot allocate memory | Error: package/namespace load failed for 'optmatch' | | optmatch.so appears to be where R is looking for it so I don't know what | has gone wrong. Have I missed something in the installation process, or Looks like a runtime error, possible due to mismatched libraries. | is this a known Ubuntu problem, or a licensing issue? Should I direct this | question to the maintainer? Possibly, the r-sig-debian list is also 'on topic' for Debian/Ubuntu questions. Hth, Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R Icon dulled out
Hi there, For some strange reason the R icon on my quickstart menu and desktop icon has suddenly dulled out to grey instead of the usual blue colour! I didnt do anything out of the ordinary which might cause this! R seems to be working fine but this problem is still bugging me!! I have tried uninstalling and reinstalling R but with no luck! Has anyone else had the same problem? version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 5.0 year 2007 month 04 day23 svn rev41293 language R version.string R version 2.5.0 (2007-04-23) Regards Wayne -- View this message in context: http://www.nabble.com/R-Icon-dulled-out-tf4018482.html#a11412808 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to get the position of an element in a vector ?
Hi, dear R developers, I've got a vector of monthly volatilities and i would like to get the position of the highest volatility of the vector without computing a loop. Is there a function that could give me such a result ? a<-c(1,2,4,100,3) the highest value is the fourth of the vector. how can i get "4" without a loop going through the vector ? Thanks ! Benoit. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop causes syntax error in print()
Duncan Murdoch wrote: > On 7/3/2007 1:59 AM, Ivan Baxter wrote: >> I am having trouble printing a table out to the GUI display when the >> table is created and printed within a loop. >> >> I get a "Error: syntax error message" >> >> If I comment out the print statement, the loop runs fine and I can >> print out the last iteration of the table. > > You should simplify your loop until it's something you can post for us > to try. Chances are you'll notice the error when you do that, but if > not, someone else will be able to tell you what's going on. > > Without a reproducible example, it's more or less hopeless. > > Duncan Murdoch Right- well I did as you suggested and seem to have fixed the problem. The problem appeared to be that some carriage returns were not registering in the Mac Os X R editor. So even though it looked like it was on a new line, it wasn't. It wasn't a line wrap issue, these were actually returns that I had hit that just weren't registering. I had one chunk of code which showed what I thought was the problem when R crashed. When I opened up the script again after restarting, the problem disappeared, so somehow the returns started to be seen. thanks for your help. Ivan > >> >> ...[multiple loops and calculations ending with.]... >> >> + print(paste(mutType,"sim",sim,"hmm",hmm)) >> + # print(acctab[,10:15]) >> ++ nummod <- nummod +1 >> + } #end hmmMats loop >> + } #end tmats loop + } #end mut type loop >> [1] "dup sim Imod hmm Jmod" >> >> > print(acctab[,10:15]) >> hitrate falsepos multrate avghit avgmiss avgfalsepos >> 1 0.0001NaN NaN 2 NA >> 2 1.0000 0.5.33 NaN NA >> 3 0.000 NaNNaN NaN 9 NA >> 4 0.7780 0. 15.571429 11 NA >> 5 1.0000 0. 24.08 NaN NA >> 6 1.0000 0.07692308 64.538462 NaN NA >> 7 1.0000 0.39207048 1088.454846 NaN NA >> >> you can see that >> a) the print statement above it works >> b) the print command works with this table >> >> but if I uncomment it and try to run the loops again. >> >> + print(paste(mutType,"sim",sim,"hmm",hmm)) >> print(acctab[,10:15]) >> Error: syntax error >> > > > nummod <- nummod +1 >> > } #end hmmMats loop >> Error: syntax error >> > } #end tmats loop Error: syntax error >> > } #end mut type loop >> Error: syntax error >> >> >> I have tried print.data.frame, but that doesn't work either >> >> >> Any suggestions would be appreciated (session info below) >> >> >> Ivan >> >> >> > sessionInfo() >> R version 2.5.1 (2007-06-27) >> i386-apple-darwin8.9.1 >> >> locale: >> C >> >> attached base packages: >> [1] "stats" "graphics" "grDevices" "utils" "datasets" >> "methods" "base" > -- ** Ivan Baxter Research Scientist Bindley Bioscience Center Purdue University Office: Hort 305 765-543-7288 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] EWMA procedure to forecast variance
Hi Have a look on ewmaSmooth function in the qcc package. Also there are some other functions in the spc package, but the qcc should be your meaning. livia <[EMAIL PROTECTED]> wrote: Hello, I would like to use the Exponential Weighted Moving Average procedure to get the variance. Is there any R function for doing this? Many thanks. -- View this message in context: http://www.nabble.com/EWMA-procedure-to-forecast-variance-tf4018317.html#a11412324 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - Be a PS3 game guru. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get the position of an element in a vector ?
?which.max 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 [EMAIL PROTECTED] www.inbo.be Do not put your faith in what statistics say until you have carefully considered what they do not say. ~William W. Watt A statistical analysis, properly conducted, is a delicate dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney > -Oorspronkelijk bericht- > Van: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Namens Benoit Chemineau > Verzonden: dinsdag 3 juli 2007 16:12 > Aan: r-help@stat.math.ethz.ch > Onderwerp: [R] how to get the position of an element in a vector ? > > Hi, dear R developers, > > I've got a vector of monthly volatilities and i would like to > get the position of the highest volatility of the vector > without computing a loop. > Is there a function that could give me such a result ? > > a<-c(1,2,4,100,3) > > the highest value is the fourth of the vector. > how can i get "4" without a loop going through the vector ? > > Thanks ! > > Benoit. > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to get the position of an element in a vector ?
which(a==max(a)) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 03/07/07, Benoit Chemineau <[EMAIL PROTECTED]> wrote: > > Hi, dear R developers, > > I've got a vector of monthly volatilities and i would like to get the > position of the highest volatility of the vector without computing a loop. > Is there a function that could give me such a result ? > > a<-c(1,2,4,100,3) > > the highest value is the fourth of the vector. > how can i get "4" without a loop going through the vector ? > > Thanks ! > > Benoit. > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fwd: help again
i try to predict the drought from the precipitation index of each month for 100 year, from 1985 to 2006 here is my code, i have the pdsi<-read.csv("pdsi.csv") pdsi<-ts(pdsi,start=1985,freq=100) HoltWinters(pdsi) plot(pdsi) lines(HoltWinters(pdsi)$fitted,col="red") pdsi.hw<-HoltWinters(pdsi) predict(pdsi.hw,n.ahead=48) plot(pdsi,xlim=c(1985,2006)) lines(predict(pdsi.hw,n.ahead=48),col=2) my error message is *Error in xy.coords(x, y) : 'x' and 'y' lengths differ* ** if anyone know please give me advice *thank in advance* *jam* [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Formula syntax question
Isaac Kohane wrote: > Forgive me if this is obvious: > > I have a frame of data with the variables in each column (e.g. > Discrete_Variable1, ContinuousVariable_1, ContinuousVariable_2, ... > ContinuousVariable_n) > > and I want to create a model using lrm i.e. > model <- lrm(Discrete_Variable1 ~ ContinuousVariable_1, > data=lotsofdata) > > Is there a syntax for having all the continuous variables referenced > in the formula without having to enumerate them all? > > I've seen the ~ . notation but when I try > > > model <- lrm(Discrete_Variable1 ~ ., data=lotsofdata) > > I get this error: > > Error in terms.formula(formula, specials = "strat") : > '.' in formula and no 'data' argument > > > Any help is appreciated. > > -Zak It may be best to write a function to determine what is continuous (>= 10 unique values for example, and numeric) and to run sapply on that function, over your data frame. Then you could use lrm(y ~ ., data=mydata[continuous]) if it were not for a problem with lrm which Charles Thomas Dupont (the Design package maintainer) and I will work on. Until then you can write a command to compose a formula, e.g., form <- as.formula(paste('y', paste(names(mydata)[continuous], collapse='+'), sep='~')) lrm(form, data=mydata) -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Formula syntax question
Forgive me if this is obvious: I have a frame of data with the variables in each column (e.g. Discrete_Variable1, ContinuousVariable_1, ContinuousVariable_2, ... ContinuousVariable_n) and I want to create a model using lrm i.e. model <- lrm(Discrete_Variable1 ~ ContinuousVariable_1, data=lotsofdata) Is there a syntax for having all the continuous variables referenced in the formula without having to enumerate them all? I've seen the ~ . notation but when I try model <- lrm(Discrete_Variable1 ~ ., data=lotsofdata) I get this error: Error in terms.formula(formula, specials = "strat") : '.' in formula and no 'data' argument Any help is appreciated. -Zak [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Parsimony Analysis of Encemism in R?
Hi R-gurus, Is there a package for "Parsimony Analysis of Endemism" (Cladist) in R? Kind regards, Miltinho Brazil http://yahoo.com.br/oqueeuganhocomisso [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] EWMA in fMultivar
Hello, I would like to use the function EWMA() in the fMultivar Package and I have a series of data x, which is the returns series. Basically, I would like to get the variance estimation using EWMA. I am trying something like EWMA(x, lambda) and I have a couple of questions: Should x be the returns series or price series in my case? When I get the result, there are the same numbers of data points as in the returns series. I was expecting there would be one less data points than the original data series, or are they one period lagged data? Could anyone give me some advice? Many thanks -- View this message in context: http://www.nabble.com/EWMA-in-fMultivar-tf4018921.html#a11414114 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] generating correlated Bernoulli random variables
Thanks, all for your help! vineet On 7/3/07, Bernhard Klingenberg <[EMAIL PROTECTED]> wrote: > > > > > > Hi all, > > > I was wondering how to generate samples for two RVs X1 and X2. > > > > > > X1 ~ Bernoulli (p1) > > > X2 ~ Bernoulli (p2) > > > > > > Also, X1 and X2 are correlated with correlation \rho. > > > > You can use the rmvbin() function in the bindata package, e.g., > > require(bindata) > n=10 > p1=0.5 > p2=0.3 > rho=0.2 > rmvbin(n, c(p1,p2), bincorr=(1-rho)*diag(2)+rho) > ?rmvbin > > However, as pointed out before, rho is bounded below and above by some > function of the marginal probabilities. (Try above code with rho=0.9) > You may want to use the odds ratio (which is unrestricted) to specify > the association between the two binary variables and then convert this > odds ratio, for given marginal probabilities p1 and p2, into a (valid) > correlation rho to be used in rmvbin(). > > Here is some ad hoc code to do that: > > bincorr <- function(OR, p1, p2) {#from odds ratio to binary > correlation > if (OR==1) p11=p2-p2+p1*p2 else { > p11_1=p2-(1/2/(1-OR)*(1-p1+OR*p1+p2-OR*p2- > sqrt((-1+p1-OR*p1-p2+OR*p2)^2-4*(1-OR)*(p2-p1*p2 > p11_2=p2-(1/2/(1-OR)*(1-p1+OR*p1+p2-OR*p2- > sqrt((-1+p1-OR*p1-p2+OR*p2)^2)-4*(1-OR)*(p2-p1*p2))) > if (p11_1>0 && p11_1<=p1 && p11_1 } > bincorr=(p11-p1*p2)/sqrt(p1*(1-p1)*p2*(1-p2)) > return(bincorr) > } > > For instance, try > > sapply(c(0,0.5,1,1.5,3,10,100),function(x) bincorr(x,p1,p2)) > > to see the range of valid correlations for odds ratios between 0 and > 100, with p1 and p2 as above. > > > Bernhard Klingenberg > Dept. of Mathematics and Statistics > Williams College, MA > www.williams.edu/~bklingen > > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to use mle with a defined function
Lin Pan yahoo.com> writes: > > > Hi all, > > I am trying to use mle() to find a self-defined function. Here is my > function: > > test <- function(a=0.1, b=0.1, c=0.001, e=0.2){ > > # omega is the known covariance matrix, Y is the response vector, X is the > explanatory matrix > > odet = unlist(determinant(omega))[1] > > # do cholesky decomposition > > C = chol(omega) > > # transform data > > U = t(C)%*%Y > WW=t(C)%*%X > > beta = lm(U~W)$coef > > Z=Y-X%*%beta > V=solve(t(C), Z) > > 0.5*odet + 0.5*(t(V)%*%V) > > } > > and I am trying to call mle() to calculate the maximum likelihood estimates > for function (0.5*odet+0.5*(t(V)%*%V)) by > > result = mle(test, method="Nelder-Mead") > > But I get the following error message: > > Error in optim(start, f, method = method, hessian = TRUE, ...) : > (list) object cannot be coerced to 'double' Can you give a self-contained example (e.g., make up a small matrix?) There are a few places where I don't understand what you're doing: - is the WW above a typo for W? - if omega is fixed, why calculate its (log) determinant every time the function is called? (this shouldn't change the answer, just slow things down) - is X a single vector or a design matrix? it seems like you might want lm(U~W-1) instead of lm(U~W) - it doesn't look like your parameters are used in the function at all -- are they really parameters for calculating omega? [because of this, I can get as far as computing the Hessian, and then I get "system is exactly singular"] [ off topic: somewhat disturbingly, the CAPTCHA word for posting from Gmane was mother f***ers ... ] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice: shifting strips to left of axes
[EMAIL PROTECTED] wrote: > On 7/2/07, Michael Hoffman <[EMAIL PROTECTED]> wrote: >> Consider this plot: >> >> xyplot(mpg ~ disp | cyl, mtcars, strip=F, strip.left=T, layout=c(1, 3), >> scales=list(relation="free"), >> par.settings=list(strip.background=list(col="transparent"))) >> >> I want to have the "cyl" strip labels on the left side of the axis. Is >> this possible? > > No. (It's possible to have a legend there, which could be used to put > row-specific ylab-s, for example, but it will be hard to make it look > like strips) Thanks for the response. Not looking like a real strip is fine. What I want is essentially a secondary ylab for each row, and don't care about niceties such as shingle markings (I should have made the conditional factor(cyl) in the above plot). But it looks like the legend goes to the left of the plot's ylab, and what I really want is for the secondary ylab to be between the primary ylab and the panel. So looks like I would have to eliminate the primary ylab from being drawn automatically and draw it myself in the legend? And I think I would have to manually calculate the panel heights as well, right? I don't see a way for the legend to get this out of the trellis object. > xyplot(mpg ~ disp | cyl, mtcars, strip=F, strip.left=T, layout=c(1, 3), >scales=list(relation="free", y = list(draw = FALSE)), >axis = function(side, ...) { >if (side == "right") >panel.axis(side = "right", outside = TRUE) >else axis.default(side = side, ...) >}, >par.settings= >list(strip.background=list(col="transparent"), > layout.widths = list(axis.key.padding = 5))) This seems a lot easier. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Blank margin in plot figures
Hello, Im using the command: xfig(file='teste.fig') plot(seq(from=0,to=21,by=0.1),dweibull(seq(from=0,to=21,by=0.1),scale=10,shape=1),type='l') dev.off() to save a the plot on format *.fig, and I use JFig to convert to *eps with the objective of use this image in a latex report. But the figure have a very big blank left margin, and it cant be centred in the text. How I can save plot in *, fig format without this margin? Best regards, Ricardo Bessa _ [[trailing spam removed]] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Search a function name in a string
Hello, I am trying to find a function name in a string that expresses a functional form : > s = "blabla...S(var)...blabla" I would like to detect the pattern "S(*)" in s. I am no guru at regular expressions. Just tried : > grep("S(.*)",c("S(a)","CSP")) [1] 1 2 > I expected the pattern to be retrieved only in the first string, so obviously this is not correct. Any idea ? Thank you very much in advance, Yvonnick Noel, PhD U. of Rennes 2 France __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Empirical copula in R
Hi, I would like to implement the empirical copula in R, does anyone know if it is included in a package? I know it is not in the "Copula" package. This one only includes a gof-test based on the empirical copula process. Thanks for your help! Gregor -- View this message in context: http://www.nabble.com/Empirical-copula-in-R-tf4018319.html#a11412335 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] loop causes syntax error in print()
On 7/3/2007 10:23 AM, Ivan Baxter wrote: > > Duncan Murdoch wrote: >> On 7/3/2007 1:59 AM, Ivan Baxter wrote: >>> I am having trouble printing a table out to the GUI display when the >>> table is created and printed within a loop. >>> >>> I get a "Error: syntax error message" >>> >>> If I comment out the print statement, the loop runs fine and I can >>> print out the last iteration of the table. >> >> You should simplify your loop until it's something you can post for us >> to try. Chances are you'll notice the error when you do that, but if >> not, someone else will be able to tell you what's going on. >> >> Without a reproducible example, it's more or less hopeless. >> >> Duncan Murdoch > Right- well I did as you suggested and seem to have fixed the problem. > > The problem appeared to be that some carriage returns were not > registering in the Mac Os X R editor. So even though it looked like it > was on a new line, it wasn't. It wasn't a line wrap issue, these were > actually returns that I had hit that just weren't registering. I had one > chunk of code which showed what I thought was the problem when R > crashed. When I opened up the script again after restarting, the problem > disappeared, so somehow the returns started to be seen. > If you can reproduce this in the future, it might be worth trying to use cut and paste to save a record of the offending text, and sending it to the Mac GUI maintainers. I would guess there's some special code that is shown by the editor as a newline but seen by the parser as just another character. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] EWMA in fMultivar
To calculate variance (assuming zero mean, as is usual), you would use returns^2. You will have to examine the code by typing EWMA to see what it's doing and how to change it. The code is clear enough that you could make your own version to achieve what you want. HTH, David L. Reiner Rho Trading Securities, LLC 550 W. Jackson Blvd #1000 Chicago, IL 60661-5704 312-244-4610 direct 312-244-4500 main 312-244-4501 fax -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of livia Sent: Tuesday, July 03, 2007 9:59 AM To: r-help@stat.math.ethz.ch Subject: [R] EWMA in fMultivar Hello, I would like to use the function EWMA() in the fMultivar Package and I have a series of data x, which is the returns series. Basically, I would like to get the variance estimation using EWMA. I am trying something like EWMA(x, lambda) and I have a couple of questions: Should x be the returns series or price series in my case? When I get the result, there are the same numbers of data points as in the returns series. I was expecting there would be one less data points than the original data series, or are they one period lagged data? Could anyone give me some advice? Many thanks -- View this message in context: http://www.nabble.com/EWMA-in-fMultivar-tf4018921.html#a11414114 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] EWMA in fMultivar
there is an ewma example in ?filter I think that might be more useful because then you can see better What's happening in terms of the smoothing. Actually, I just looked and it's not there. It must have been in S+. I include my ewma below but you have to modify it because it assumes a zoo object. Of coure, The other option you have is to look at the source code for the ewma function in fMultvar. ewma<-function(x,lambda = 1, init = (1-lambda)*.raw[good.ind][1]) { # work with 'non-zoo' data for speed and then recombine .raw <- unclass(coredata(x)) good.ind <- !is.na(.raw) # determine good values .raw[good.ind] <- filter(lambda * .raw[good.ind], filter=(1-lambda), method='recursive', init=coredata(init)) zoo(.raw, index(x)) # create zoo object for return -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of livia Sent: Tuesday, July 03, 2007 10:59 AM To: r-help@stat.math.ethz.ch Subject: [R] EWMA in fMultivar Hello, I would like to use the function EWMA() in the fMultivar Package and I have a series of data x, which is the returns series. Basically, I would like to get the variance estimation using EWMA. I am trying something like EWMA(x, lambda) and I have a couple of questions: Should x be the returns series or price series in my case? When I get the result, there are the same numbers of data points as in the returns series. I was expecting there would be one less data points than the original data series, or are they one period lagged data? Could anyone give me some advice? Many thanks -- View this message in context: http://www.nabble.com/EWMA-in-fMultivar-tf4018921.html#a11414114 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Search a function name in a string
NOEL Yvonnick wrote: > Hello, > > I am trying to find a function name in a string that expresses a > functional form : > > > s = "blabla...S(var)...blabla" > > I would like to detect the pattern "S(*)" in s. > > I am no guru at regular expressions. Just tried : > > > grep("S(.*)",c("S(a)","CSP")) grep("S\\(.*\\)",c("S(a)","CSP")) Uwe Ligges > [1] 1 2 > > > > I expected the pattern to be retrieved only in the first string, so > obviously this is not correct. Any idea ? > > Thank you very much in advance, > > Yvonnick Noel, PhD > U. of Rennes 2 > France > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MatchIt package on Ubuntu 7.04 (Feisty Fawn)
Dirk, Thanks for the assistance. > -Original Message- > From: Dirk Eddelbuettel [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 03, 2007 6:57 AM > To: Daniel Nordlund > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] MatchIt package on Ubuntu 7.04 (Feisty Fawn) > > > On 2 July 2007 at 23:47, Daniel Nordlund wrote: > | I tried to install the MatchIt package on Ubuntu 7.04. > > How? Via 'sudo apt-get install r-cran-matchit', or using R? Using install.packages() inside R. > > | When loading required dependencies I got the following error message: > | > | Error in dyn.load(x, as.logical(local), as.logical(now)) : > | unable to load shared library > | '/usr/local/lib/R/site-library/optmatch/libs/optmatch.so': > > /usr/local, so you did this using via 'R CMD INSTALL ' or from inside > R. Consider removing this directory and install the Ubuntu-supplied package. > Also, you didn't mention whether this is an older install of matchit, or > whether you just did it. This is a new install using install.packages(). I will try your suggestions and maybe move further questions to r-sig-debian. > > | /usr/local/lib/R/site-library/optmatch/libs/optmatch.so: cannot map > zero-fill pages: > Cannot allocate memory > | Error: package/namespace load failed for 'optmatch' > | > | optmatch.so appears to be where R is looking for it so I don't know what > | has gone wrong. Have I missed something in the installation process, or > > Looks like a runtime error, possible due to mismatched libraries. > > | is this a known Ubuntu problem, or a licensing issue? Should I direct this > | question to the maintainer? > > Possibly, the r-sig-debian list is also 'on topic' for Debian/Ubuntu > questions. > > Hth, Dirk > Thanks again, Dan Daniel Nordlund Bothell, WA USA __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Search a function name in a string
Parnetheses have special meaning so they must be escaped or specify a character class of 1: > grep("S\\(.*\\)",c("S(a)","CSP")) [1] 1 > grep("S[(].*[)]",c("S(a)","CSP")) [1] 1 On 7/3/07, NOEL Yvonnick <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to find a function name in a string that expresses a > functional form : > > > s = "blabla...S(var)...blabla" > > I would like to detect the pattern "S(*)" in s. > > I am no guru at regular expressions. Just tried : > > > grep("S(.*)",c("S(a)","CSP")) > [1] 1 2 > > > > I expected the pattern to be retrieved only in the first string, so > obviously this is not correct. Any idea ? > > Thank you very much in advance, > > Yvonnick Noel, PhD > U. of Rennes 2 > France > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] xyplot and autokey, maintaining colors specified via "col" in key
All, When specifying colors to xyplot w/ a groups argument, using auto.key no longer maintains the colors properly. I've searched the docs and help but haven't found exactly what I need ... I saw a few examples in the archives involving par.settings but that doesn't seem to do it. I also saw some people using key instead of auto.key, but that didn't seem consistent. Is there a quick fix to the example code below? cheers, Dave dat.ex = data.frame( rep(c(1:6), each=6), c(rnorm(12), rnorm(12, 1), rnorm(12, 2)), rep(c(1:6), 6), rep(c("Drug1", "Drug2", "Placebo"), each=12) ) names(dat.ex) = c("patient.no", "outcome", "time", "drug") ## colors in xyplot agree w/ colors in key, colors not specified: xyplot(outcome ~ time, dat.ex, groups=drug, type=c("g", "smooth"), auto.key = list(space = "top", text = levels(dat.ex$drug), points=FALSE, lines=TRUE ) ) ## colors in xyplot do NOT agree w/ colors in key when colors changed: xyplot(outcome ~ time, dat.ex, groups=drug, type=c("g", "smooth"), auto.key = list(space = "top", text = levels(dat.ex$drug), points=FALSE, lines=TRUE ), col = c(1,2,3) ) i.e., the key is still generated w/ the "old" colors. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] sequences
Hi, I would like to generate a series in the following form (0.8^1, 0.8^2, ..., 0.8^600) Could anyone tell me how can I achieve that? I am really new to R. -- View this message in context: http://www.nabble.com/sequences-tf4019146.html#a11414836 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sequences
0.8^(1:600) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O On 03/07/07, livia <[EMAIL PROTECTED]> wrote: > > > Hi, I would like to generate a series in the following form (0.8^1, 0.8^2, > ..., 0.8^600) > Could anyone tell me how can I achieve that? I am really new to R. > -- > View this message in context: > http://www.nabble.com/sequences-tf4019146.html#a11414836 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sequences
Just take advantage of R's vectorized calculations as x <- seq(1:600) .8^x Harold > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of livia > Sent: Tuesday, July 03, 2007 12:05 PM > To: r-help@stat.math.ethz.ch > Subject: [R] sequences > > > Hi, I would like to generate a series in the following form > (0.8^1, 0.8^2, ..., 0.8^600) Could anyone tell me how can I > achieve that? I am really new to R. > -- > View this message in context: > http://www.nabble.com/sequences-tf4019146.html#a11414836 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sequences
livia wrote: > Hi, I would like to generate a series in the following form (0.8^1, 0.8^2, > ..., 0.8^600) > Could anyone tell me how can I achieve that? I am really new to R. 8^(1:600) -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] xyplot and autokey, maintaining colors specified via "col" in key
Don't know what you did regarding par.settings to not get the desired result but that is, in fact, the way to go since both the key and the plot lines will get their colors from that: xyplot(outcome ~ time, dat.ex, groups=drug, type=c("g", "smooth"), auto.key = list(space = "top", text = levels(dat.ex$drug), points=FALSE, lines=TRUE ), par.settings = list(superpose.line = list(col = rainbow(3 On 7/3/07, Afshartous, David <[EMAIL PROTECTED]> wrote: > > All, > > When specifying colors to xyplot w/ a groups argument, using > auto.key no longer maintains the colors properly. I've searched > the docs and help but haven't found exactly what I need ... I saw > a few examples in the archives involving par.settings but that doesn't > seem to do it. I also saw some people using key instead of auto.key, but > that didn't seem consistent. Is there a quick fix to the example code > below? > > cheers, > Dave > > dat.ex = data.frame( rep(c(1:6), each=6), c(rnorm(12), rnorm(12, 1), > rnorm(12, 2)), rep(c(1:6), 6), > rep(c("Drug1", "Drug2", "Placebo"), each=12) ) > names(dat.ex) = c("patient.no", "outcome", "time", "drug") > > > ## colors in xyplot agree w/ colors in key, colors not specified: > xyplot(outcome ~ time, dat.ex, groups=drug, type=c("g", "smooth"), > auto.key = list(space = "top", text = levels(dat.ex$drug), > points=FALSE, lines=TRUE ) ) > > ## colors in xyplot do NOT agree w/ colors in key when colors changed: > xyplot(outcome ~ time, dat.ex, groups=drug, type=c("g", "smooth"), > auto.key = list(space = "top", text = levels(dat.ex$drug), > points=FALSE, lines=TRUE ), > col = c(1,2,3) ) > > i.e., the key is still generated w/ the "old" colors. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] bug in closing gzfile-opened connections?
Hi, I am making multiple calls to gzfile() via read.table(), e.g. > x <- read.table( gzfile( "xxx.gz" ) ) After i do this many times (I haven't counted, but probably between 50 and 100 times) I get the error message: Error in open.connection(file, "r") : unable to open connection In addition: Warning message: cannot open compressed file 'xxx.gz' however, I also find that: > showConnections() description class mode text isopen can read can write so there are no (apparently) open connections. Calling closeAllConnections() does not fix the problem. I have to quit and re-start R. I am using R 2.5.0 on a Mac (OSX 10.4.9). Anyone know if this is a bug or a 'feature'? I see from the gzfile help that: In general functions using connections will open them if they are not open, but then close them again, so to leave a connection open call 'open' explicitly. Thanks. -David [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice: shifting strips to left of axes
On 7/3/07, Michael Hoffman <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > On 7/2/07, Michael Hoffman <[EMAIL PROTECTED]> wrote: > >> Consider this plot: > >> > >> xyplot(mpg ~ disp | cyl, mtcars, strip=F, strip.left=T, layout=c(1, 3), > >> scales=list(relation="free"), > >> par.settings=list(strip.background=list(col="transparent"))) > >> > >> I want to have the "cyl" strip labels on the left side of the axis. Is > >> this possible? > > > > No. (It's possible to have a legend there, which could be used to put > > row-specific ylab-s, for example, but it will be hard to make it look > > like strips) > > Thanks for the response. > > Not looking like a real strip is fine. What I want is essentially a > secondary ylab for each row, and don't care about niceties such as > shingle markings (I should have made the conditional factor(cyl) in the > above plot). I thought this might be the case. > But it looks like the legend goes to the left of the plot's ylab, and > what I really want is for the secondary ylab to be between the primary > ylab and the panel. So looks like I would have to eliminate the primary > ylab from being drawn automatically and draw it myself in the legend? > And I think I would have to manually calculate the panel heights as > well, right? I don't see a way for the legend to get this out of the > trellis object. It's possible, although it requires some advanced grid features. Luckily, this has come up before (search the r-help archives for "myXlabGrob"). Basically, you can use the fact that 'ylab' can be a "grob" to get what you want (I think). Here is a modified version of the original function (adapted to include a 'primary' ylab): library(grid) library(lattice) myYlabGrob <- function(..., main.ylab = "") ## ...is lab1, lab2, etc { ## you can add arguments to textGrob for more control ## in the next line labs <- lapply(list(...), textGrob, rot=90) main.ylab <- textGrob(main.ylab, rot = 90) nlabs <- length(labs) lab.heights <- lapply(labs, function(lab) unit(1, "grobheight", data=list(lab))) unit1 <- unit(1.2, "grobheight", data = list(main.ylab)) unit2 <- do.call(max, lab.heights) lab.layout <- grid.layout(ncol = 2, nrow = nlabs, heights = unit(1, "null"), widths = unit.c(unit1, unit2), respect = TRUE) lab.gf <- frameGrob(layout=lab.layout) for (i in seq_len(nlabs)) { lab.gf <- placeGrob(lab.gf, labs[[i]], row = i, col = 2) } lab.gf <- placeGrob(lab.gf, main.ylab, col = 1) lab.gf } xyplot(mpg ~ disp | cyl, mtcars, strip=F, strip.left=F, layout=c(1, 3), scales=list(relation="free"), ylab = myYlabGrob("4", "6", "8", main.ylab = "mpg")) -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] vertically concatenating data frames
Hi, what is the recommended way to vertically concatenate 2 data frames with the same column names but different number of rows? My problem is something along these lines: df1 <- data.frame(var1=var1,var2=var2,var3=var3) # nrow(df1)=1000 df2 <- data.frame(var1=var4,var2=var5,var3=var6) # nrow(df2)=2000 I tried df <- c(df1,df2), no success. stack does not seem to be appropriate either for my problem. Thanks Zava This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vertically concatenating data frames
Use rbind instead of c: > df <- rbind(df1,df2) Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] (801) 408-8111 > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Aydemir, Zava (FID) > Sent: Tuesday, July 03, 2007 12:01 PM > To: r-help@stat.math.ethz.ch > Subject: [R] vertically concatenating data frames > > Hi, > > what is the recommended way to vertically concatenate 2 data > frames with the same column names but different number of rows? > > My problem is something along these lines: > > df1 <- data.frame(var1=var1,var2=var2,var3=var3) # nrow(df1)=1000 > df2 <- data.frame(var1=var4,var2=var5,var3=var6) # nrow(df2)=2000 > > I tried df <- c(df1,df2), no success. stack does not seem to > be appropriate either for my problem. > > > Thanks > > Zava > > > This is not an offer (or solicitation of an offer) to > buy/se...{{dropped}} > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Using odesolve to produce non-negative solutions
If you didn't get this solved. I have done parameter estimation with models defined by ODE's where negative solutions are a problem and one can only avoid them with great difficulty if the standard explicit methods for solving the ODE are used. I found that using implicit methods could be a great help. For example in the exponential case dN/dt = -k*N the simple finite difference approximation is N_{t+1}-N+t -- = -k*N_t , k>=0 h or N_{t+1} = N_t -k*h*N_t and if k*h gets too large N_{t+1} goes negative and you are in trouble. Consider instead the implicit formulation where the second N_t on the RHS is replaced by N_{t+1} and one gets N_{t+1} = N_t/(1+k*h) which is correct for k*h=0 and as k*h--> infinity For a more complicated example see http://otter-rsch.com/admodel/cc4.html for something I called "semi-implicit". I hope these ideas will be useful for your problem. Cheers, Dave -- David A. Fournier P.O. Box 2040, Sidney, B.C. V8l 3S3 Canada Phone/FAX 250-655-3364 http://otter-rsch.com __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Convetring a dataframe so that it just has one column
I have two dataframes, yendog and datasub as below and I want to do the same thing to both of them, namely convert them so that they retain their dataframeness but stack the columns into 1 column. I don't need names on the results. I did try temp1<-do.call("rbind",datasub) temp2<-do.call("rbind",yendog) and also temp1<-do.call("rbind",lapply(datasub,function(x) { t(x) })) temp2<-do.call("rbind",lapply(yendog, function(x) { t(x) })) but neither of them did the trick. I'm probably making it more complicated than it needs to be. Thanks for any sugggestions. datasub AAA.l1BBB.l1CCC.l1DDD.l1EEE.l1 FFF.l1 2 -1.937171e-04 1.391873e-03 1.713845e-04 2.595525e-04 2.635428e-05 2.047188e-04 3 3.228410e-04 6.047229e-05 1.713551e-04 7.414547e-05 -4.744833e-04 -3.070939e-04 4 0.00e+00 1.209336e-04 -1.142335e-04 -7.414547e-05 -1.318409e-04 0.00e+00 5 -1.291239e-04 -4.838222e-04 -6.856751e-04 -2.966369e-04 -7.650202e-04 2.047397e-04 6 -1.937171e-04 -1.814937e-04 0.00e+00 0.00e+00 -5.278159e-05 2.046978e-04 7 0.00e+00 -6.050522e-05 2.286106e-04 5.190568e-04 4.749340e-04 5.115613e-04 8 1.291489e-04 3.629764e-04 4.570645e-04 1.482525e-04 1.582612e-04 2.045513e-04 9 -3.229036e-04 -1.814717e-04 -7.428360e-04 -5.931418e-04 -7.123729e-04 -2.045513e-04 10 8.393325e-04 7.256894e-04 1.714727e-04 3.708167e-05 7.917761e-05 -2.557479e-04 11 6.451613e-04 0.00e+00 1.142988e-04 2.224612e-04 -2.639497e-04 -4.093328e-04 12 1.934673e-04 0.00e+00 -1.142988e-04 -3.707342e-05 -5.279831e-05 5.117576e-05 13 -1.096810e-03 3.022152e-04 0.00e+00 -1.483074e-04 -2.376269e-04 1.023437e-04 14 7.098377e-04 -1.208751e-04 6.855968e-04 3.707274e-04 2.640578e-05 7.672438e-04 16 3.224454e-04 1.087613e-03 -5.712490e-05 2.223870e-04 3.695101e-04 3.066858e-04 17 9.022945e-04 2.171685e-03 6.281945e-04 6.668643e-04 5.803831e-04 4.087681e-04 18 -6.442261e-05 -7.233709e-04 1.712573e-04 -7.407407e-05 1.054880e-04 -1.021764e-04 19 -1.224819e-03 -1.206782e-03 -1.142270e-03 -8.151772e-04 -7.911497e-05 0.00e+00 20 3.869470e-04 -1.811430e-04 -5.144474e-04 -7.416472e-04 1.318548e-04 -5.621567e-04 21 -1.934548e-04 1.811430e-04 2.858368e-04 1.483735e-04 -7.911079e-05 5.110646e-04 22 -1.934922e-04 6.035732e-04 5.715755e-05 -1.112780e-04 5.274123e-05 -3.066074e-04 23 -7.097919e-04 0.00e+00 1.714531e-04 1.854565e-04 -1.054852e-04 0.00e+00 24 -7.748935e-04 1.206709e-04 1.142857e-04 3.708717e-05 1.845919e-04 0.00e+00 25 -5.815644e-04 -4.827711e-04 -4.000572e-04 -1.112656e-04 -1.054769e-04 1.022129e-04 26 -5.172302e-04 1.207146e-04 -4.574042e-04 -4.080800e-04 1.318444e-04 -3.577909e-04 27 2.586486e-04 -6.641109e-04 -4.004004e-04 -5.196155e-04 -5.273566e-05 5.112082e-05 28 1.292992e-04 1.207802e-04 0.00e+00 1.856080e-04 -1.582237e-04 5.111821e-05 29 1.292825e-04 0.00e+00 -5.721315e-05 1.113482e-04 1.582237e-04 -3.578824e-04 30 2.585148e-04 -3.623845e-04 1.716296e-04 3.710713e-04 -2.636887e-05 5.113389e-05 yendog AAA BBB CCC DDD EEE FFF 2 3.228410e-04 6.047229e-05 1.713551e-04 7.414547e-05 -4.744833e-04 -3.070939e-04 3 0.00e+00 1.209336e-04 -1.142335e-04 -7.414547e-05 -1.318409e-04 0.00e+00 4 -1.291239e-04 -4.838222e-04 -6.856751e-04 -2.966369e-04 -7.650202e-04 2.047397e-04 5 -1.937171e-04 -1.814937e-04 0.00e+00 0.00e+00 -5.278159e-05 2.046978e-04 6 0.00e+00 -6.050522e-05 2.286106e-04 5.190568e-04 4.749340e-04 5.115613e-04 7 1.291489e-04 3.629764e-04 4.570645e-04 1.482525e-04 1.582612e-04 2.045513e-04 8 -3.229036e-04 -1.814717e-04 -7.428360e-04 -5.931418e-04 -7.123729e-04 -2.045513e-04 9 8.393325e-04 7.256894e-04 1.714727e-04 3.708167e-05 7.917761e-05 -2.557479e-04 10 6.451613e-04 0.00e+00 1.142988e-04 2.224612e-04 -2.639497e-04 -4.093328e-04 11 1.934673e-04 0.00e+00 -1.142988e-04 -3.707342e-05 -5.279831e-05 5.117576e-05 12 -1.096810e-03 3.022152e-04 0.00e+00 -1.483074e-04 -2.376269e-04 1.023437e-04 13 7.098377e-04 -1.208751e-04 6.855968e-04 3.707274e-04 2.640578e-05 7.672438e-04 14 1.290073e-04 -2.417941e-04 -1.713551e-04 -7.413448e-05 2.640194e-04 1.533782e-04 16 9.022945e-04 2.171685e-03 6.281945e-04 6.668643e-04 5.803831e-04 4.087681e-04 17 -6.442261e-05 -7.233709e-04 1.712573e-04 -7.407407e-05 1.054880e-04 -1.021764e-04 18 -1.224819e-03 -1.206782e-03 -1.142270e-03 -8.151772e-04 -7.911497e-05 0.00e+00 19 3.869470e-04 -1.811430e-04 -5.144474e-04 -7.416472e-04 1.318548e-04 -5.621567e-04 20 -1.934548e-04 1.811430e-04 2.858368e-04 1.483735e-04 -7.911079e-05 5.110646e-04 21 -1.934922e-04 6.035732e-04 5.715755e-05 -1.112780e-04 5.274123e-05 -3.066074e-04 22 -7.097919e-04 0.00e+00 1.714531e-04 1.854565e-04 -1.054852e-04 0.00e+00 23 -7.748935e-04 1.206709e-04 1.142857e-04 3.708717e-05 1.845919e-04 0.00e+00 24 -5.815644e-04 -4.827
Re: [R] Convetring a dataframe so that it just has one column
?stack tmp <- data.frame(a=1:10, b=11:20) stack(tmp) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] exact AIC
Hi, I am using the stepAIC function on the MASS package that does model selection by exact AIC. I'm not sure what the term 'exact AIC' means, and how it differs from AIC. Thank you, Selene Zarate __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to calculate interaction contrast
Hello, R experts, Sorry for asking this question again since I really want a help! I have a two-factor experiment data and like to calculate estimates of interation contrasts say factor A has levels of a1, a2, and B has levels of b1, b2, b3, b4, and b5 with 3 replicates. I am not sure the constrast estimate I got is right using the script below: score<-c(7.2,6.5,6.9,6.4,6.9,6.1,6.9,5.3,7.2,5.7,5.1,5.9,7.6,6.9,6.8, 7.2,6.6,6.9,6.4,6.0,6.0,6.9,6.9,6.4,7.5,7.7,7.0,8.6,8.8,8.3) A <- gl(2, 15, labels=c("a1", "a2")) B <- rep(gl(5, 3, labels=c("b1", "b2", "b3", "b4", "b5")), 2) contrasts(B)<-cbind(c(-4,rep(1,4)),c(rep(-3,2),rep(2,3)), + c(rep(-2,3),rep(3,2)),c(rep(-1,4), rep(4,1))) fit1 <- aov(score ~ A*B) summary(fit1, split=list(B=1:4), expand.split = TRUE) Df Sum Sq Mean Sq F valuePr(>F) A1 3.2013 3.2013 15.1483 0.0009054 *** B4 8.7780 2.1945 10.3841 0.0001019 *** B: C1 1 0.0301 0.0301 0.1424 0.7099296 B: C2 1 2.0335 2.0335 9.6221 0.0056199 ** B: C3 1 1.2469 1.2469 5.9004 0.0246876 * B: C4 1 5.4675 5.4675 25.8715 5.637e-05 *** A:B 4 5.3420 1.3355 6.3194 0.0018616 ** A:B: C11 0.7207 0.7207 3.4105 0.0796342 . A:B: C21 2.6068 2.6068 12.3350 0.0021927 ** A:B: C31 1.9136 1.9136 9.0549 0.0069317 ** A:B: C41 0.1008 0.1008 0.4771 0.4976647 Residuals 20 4.2267 0.2113 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Now I like to get interaction contrast estimate for b1 and b2 vs b3, b4 and b5 cont <- c(1, -1)[A] * c(-3, -3, 2, 2, 2)[B] estimat<-sum(cont*score) # value of the contrast estimate for A:B C2 > estimat [1] -24.1 I am not sure the estimate for A:B C2 contrast (-24.1) is correct because the F value given the output above(12.3350) does not equal to those I calculate below (15.2684): t.stat <- sum(cont*score)/se.contrast(fit1, as.matrix(cont)) > t.stat^2 Contrast 1 15.2684 Could you please help me calculate the correct the estimate of interaction contrast and corresponding F value? Thanks in advance! Joshua __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. - End forwarded message - __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing packages...
I have the exact same problem as you had when I customerized some package: the way I go around this is using install.packages("~/Documents/projects/R_customerized_packages/supclust_1.0-5.tar.gz", repos=NULL, type="source") in which supclust_... is built from R CMD build supclust and in your case, you just need to download the package if you insist on using downloaded package. HTH, Weiwei On 1/23/07, Nüzhet Dalfes <[EMAIL PROTECTED]> wrote: > Hi, > > I am a total newbie to R. I am using R (2.4.1) on Mac OS X 10.4.8 and > trying to install some packages using GUI Packages & Data/Package Installer > interface... > > Every time I get: > > trying URL > 'http://umfragen.sowi.uni-mainz.de/CRAN/bin/macosx/universal/contrib/2.4/neural_1.4.1.tgz' > Content type 'application/x-tar' length 18920 bytes > opened URL > == > downloaded 18Kb > > Error in gzfile(file, "r") : unable to open connection > In addition: Warning message: > cannot open compressed file 'neural/DESCRIPTION' > > > > What am I doing wrong? > > Any help will be much appreciated. > > Nüzhet Dalfes > > Istanbul Tech. Univ. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. "Did you always know?" "No, I did not. But I believed..." ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to solve a min problem
Do you mean minimize mu with 0 < b_func(S+mu) < 800? For this kind of problem, I'd first want to know the nature of "b_func". Without knowing more, I might try to plot b_func(S+mu) vs. mu, then maybe use 'optimize'. If this is not what you mean, please be more specific: I'm confused. Hope this helps. Spencer Graves domenico pestalozzi wrote: > I know it's possible to solve max e min problems by using these functions: > > nlm, optimize, optim > > but I don't know how to use them (...if possible...) to solve this problem. > > I have a personal function called b_func(S) where S is an input array (1 X > n) and I'd like: > > minimize mean(S) with 0 < b_funct < 800. > > I know that the solution exists, but It's possible to calculate it in R? > The b_func is non linear and it calculates a particular value using S as > input and applying a convergent iterative algorithm. > > thanks > > > domenico > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] vertically concatenating data frames
?rbind --- "Aydemir, Zava (FID)" <[EMAIL PROTECTED]> wrote: > Hi, > > what is the recommended way to vertically > concatenate 2 data frames with > the same column names but different number of rows? > > My problem is something along these lines: > > df1 <- data.frame(var1=var1,var2=var2,var3=var3) # > nrow(df1)=1000 > df2 <- data.frame(var1=var4,var2=var5,var3=var6) # > nrow(df2)=2000 > > I tried df <- c(df1,df2), no success. stack does not > seem to be > appropriate either for my problem. > > > Thanks > > Zava > > > This is not an offer (or solicitation of an offer) > to buy/se...{{dropped}} > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] dlda{supclust} 's output
Hi, I modified dlda{supclust} so that the original example in ?dlda gives the following output: > set.seed(342) > xlearn <- matrix(rnorm(200), nrow = 20, ncol = 10) > > ## Generating random test data: 8 observations and 10 variables(clusters) > xtest <- matrix(rnorm(80), nrow = 8, ncol = 10) > > ## Generating random class labels for the learning data > ylearn <- as.numeric(runif(20)>0.5) > > ## Predicting the class labels for the test data > > t0 = dlda(xlearn, xtest, ylearn) > t0 [,1] [,2] [1,] 17.595758 21.20141 [2,] 11.882305 20.34470 [3,] 7.837422 12.47240 [4,] 11.025810 12.04523 [5,] 18.167740 15.91930 [6,] 11.396010 9.26949 [7,] 33.911010 26.06992 [8,] 16.140149 19.83915 (to be noticed: the above is anti-probabilities, which means the smaller, the higher prob for being the label of colname, for example, sample 5, the class label is predicted as 1 instead of 0) Here I have one question about it: since apply(t0, 1, sum) does not give the same sum, I am wondering if standardization is a proper way to compare the probabilities "BETWEEN" samples, following the understanding of dlda algorithm. Thanks, Weiwei On 5/7/07, Marcel Dettling <[EMAIL PROTECTED]> wrote: > Hi Weiwei, > > it would be possible to obtain probabilities instead of just a 0/1 > output. The code needs to be altered though. Sorry I don't have the time > to do that. But R is open source and contributions are most welcome. > > I'm sorry not to be able of more help, > > Marcel > > -- > Marcel Dettling > Phone: +41 79 489 72 04 > E-Mail: [EMAIL PROTECTED] > Web:http://stat.ethz.ch/~dettling > -- > - Original Message - > From: "Weiwei Shi" <[EMAIL PROTECTED]> > To: "R Help" > Cc: <[EMAIL PROTECTED]> > Sent: Tuesday, May 01, 2007 11:50 PM > Subject: dlda{supclust} 's output > > > > Hi, > > > > I am using dlda algorithm from supclust package and I am wondering if > > the output can be a continuous probability instead of discrete class > > label (zero or one) since it puts some restriction on convariance > > matrix, compared with lda, while the latter can. > > > > thanks, > > > > -- > > Weiwei Shi, Ph.D > > Research Scientist > > GeneGO, Inc. > > > > "Did you always know?" > > "No, I did not. But I believed..." > > ---Matrix III > > > > > > !DSPAM:4637b61518111667610022! > > > > -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. "Did you always know?" "No, I did not. But I believed..." ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reinforce library to re-load
Hi, I am wondering if there is a parameter in library() so that it can reinforce package to be reloaded. It helps when you test your modified package by yourself. Otherwise, my way is to re-start Rgui. (by reading ?library, I understand this option is not implemented) "...Both functions check and update the list of currently loaded packages and do not reload a package which is already loaded. (Furthermore, if the package has a name space and a name space of that name is already loaded, they work from the existing names space rather than reloading from the file system.)" Thanks. -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. "Did you always know?" "No, I did not. But I believed..." ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reinforce library to re-load
I think you want to use detach() > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Weiwei Shi > Sent: Tuesday, July 03, 2007 3:27 PM > To: r-help@stat.math.ethz.ch > Cc: [EMAIL PROTECTED] > Subject: [R] reinforce library to re-load > > Hi, > > I am wondering if there is a parameter in library() so that > it can reinforce package to be reloaded. It helps when you > test your modified package by yourself. Otherwise, my way is > to re-start Rgui. > > (by reading ?library, I understand this option is not > implemented) "...Both functions check and update the list of > currently loaded packages and do not reload a package which > is already loaded. > (Furthermore, if the package has a name space and a name > space of that name is already loaded, they work from the > existing names space rather than reloading from the file system.)" > > Thanks. > > -- > Weiwei Shi, Ph.D > Research Scientist > GeneGO, Inc. > > "Did you always know?" > "No, I did not. But I believed..." > ---Matrix III > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Dealing with imported data
Hello all, I am a new R user and am having some difficulty using my imported data. I have finally figured out how to import my data by using the >read.delim("Filename", header=TRUE) which took some time because I had to change the directory (a hint for others who might be struggling). However, I am now stuck on being able to use my data. I read that I will have to use some command like attach() but when I try to do anything with my data even say data.frame() I don't know how to call my data. If I say data.frame("filename") it says object not found. So basically I don't know how to call my data. Suggestions? Thanks, Susie [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problems using imported data
(Repeat of previous HTML version) Hello all, I am a new R user and I have finally imported my data using >read.delim("Filename.txt", header=TRUE) after some difficulty, by changing >file directories (a hint to anyone who might be stuck there). However, I am now stuck trying to use my data. When I try to use data.frame("filename.txt") it tells me object not found, which makes it difficult to use attach() or with(). How do I get R to recognize my data? Thanks, Susie PhD Student UCI Luggage? GPS? Comic books? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Non-linear constraints under Markowitz
I am hoping to do some portfolio optimization where I want to maximize my possible return subject to the constraint that my variance is below a certain value and no short positions. Is there a way I can use optim to do this ? thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fine tunning rgenoud
Dear All, I am trying to solve the following maximization problem, but I cannot have rgenoud giving me a reliable solution. Any ideas? Thanks in advance, Paul library(rgenoud) v <- 0.90 O1 <- 10 O2 <- 20 O0 <- v*O1+(1-v)*O2 myfunc <- function(x) { U0 <- x[1] U1 <- x[2] U2 <- x[3] q0 <- x[4] q1 <- x[5] q2 <- x[6] p <- x[7] if (U0 < 0) return(-1e+200) else if (U1 < 0) return(-1e+200) else if (U2 < 0) return(-1e+200) else if ((U0-(U1+(O1-O0)*q1)) < 0) return(-1e+200) else if ((U0-(U2+(O2-O0)*q2)) < 0) return(-1e+200) else if ((U1-(U0+(O0-O1)*q0)) < 0) return(-1e+200) else if ((U1-(U2+(O2-O1)*q2)) < 0) return(-1e+200) else if((U2-(U0+(O0-O2)*q0)) < 0) return(-1e+200) else if((U2-(U1+(O1-O2)*q1)) < 0) return(-1e+200) else if(p < 0) return(-1e+200) else if(p > 1) return(-1e+200) else if(q0 < 0) return(-1e+200) else if(q1 < 0) return(-1e+200) else if(q2 < 0) return(-1e+200) else return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2)-(O2*q2+U2 } genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.generations=150,max.generations=300,boundary.enforcement=2) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-linear constraints under Markowitz
I think that problem has a complicated closed form solution but I'm not sure which text it is in. It might be in Ingersoll, Financial Decision Making. I'm sorry that I can't be less vague. It's also possible to derive it using a Langrange Multiplier. I did it once but that was a long time ago. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Patrick C. Sent: Tuesday, July 03, 2007 3:53 PM To: r-help@stat.math.ethz.ch Subject: [R] Non-linear constraints under Markowitz I am hoping to do some portfolio optimization where I want to maximize my possible return subject to the constraint that my variance is below a certain value and no short positions. Is there a way I can use optim to do this ? thanks [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. This is not an offer (or solicitation of an offer) to buy/se...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Statistics Question not R question: competing risks and non-informative censoring
All, I am working with Emergency Department (ED) Length of Stay Data. The ED visit can end in one of a variety of ways (Admit, discharge, transfer, etc...) Initially, I have modeled the time to event by fitting a survival model to the time the outcome of interest and treat all other outcomes as censoring. However I recently came across the cmprsk package in R which seems to be developed specifically for competing risks survival models. I have been able to gather that the key issue in deciding whether to model each outcome separately or to use something like the cmprsk package is to determine whether or not the censoring is "non-informative." I have read a up a little about informative vs. no-informative censoring, but remain confused, is their a standard approach to determining whether or not censoring is informative, can anyone suggest some good (approachable/non-technical) references on the subject? best, Spencer [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] (no subject)
Hi: We are having some very strange problems with R on WIndows, both with R 2.4.1 and R 2.5.0. The following command: > download.file(url="http://oceanwatch.pfeg.noaa.gov:8081/thredds/wcs/ > satellite/AG/ssta/14day? > request=GetCoverage&version=1.0.0&service=WCS&format=NetCDF3&coverage= > AGssta&Vertical=.0&time=2006-01-06T00:00:00Z&bbox=220,20,250,50", > destfile="junk.nc") > on my Mac downloads a netcdf file, which I can open just fine using the ncdf package, and displays just fine using the netcdf utility "ncdump -h" The same command under Windows downloads a file with that name and with the correct size. A cmp on the two files says there are differences, and using a hex editor confirms this. The file produces a simple error when using "open.ncdf" and in fact the ncdump utility produces: rmendels% /sw/bin/ncdump -h junk1.nc /sw/bin/ncdump: junk1.nc: Invalid argument There is clearly something corrupted in the Wndows version, and yet it works perfectly on my Mac. I have produced this error on two different Windows machines with two different versions of R. Any help appreciated -Roy M. ** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center 1352 Lighthouse Avenue Pacific Grove, CA 93950-2097 e-mail: [EMAIL PROTECTED] (Note new e-mail address) voice: (831)-648-9029 fax: (831)-648-8440 www: http://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Harrell's C
I need to calculate Harrell's C for some survival analyses using Design package with R version 2.4.1. ¿How can I try or do it? Rosario Madero Sección de Bioestadística Hospital Universitario La Paz Pºde la Castellana, 261 28046 Madrid, España Tfno: 917277112 [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Kullback-Leibler divergence
Dear R users, Is anyone willing to share some sample code using R that calculates the Kullback-Leibler divergence in information contained in the the posterior distribution relative to the prior for some simple continuous distribution such as a normal? We are thinking of an informative prior and using Kullback-Leibler to quantify how much information is gained from the merging of the data with the prior. Terrence E. Murphy, Ph.D. Program on Aging Yale University 300 George St., Suite 775 New Haven, CT 06511 [EMAIL PROTECTED] phone: 203-737-2295 fax: 203-785-4823 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fine tunning rgenoud
Paul, You had indicated in your previous email that you are having trouble finding a feasible starting value for constrOptim(). So, you basically need to solve a system of linear inequalities to obtain a starting point. Have you considered using linear programming? Either simplex() in the "boot" package or solveLP() in "linprog" would work. It seems to me that you could use any linear objective function in solveLP to obtain a feasible starting point. This is not the most efficient solution, but it might be worth a try. I am aware of other methods for generating n-tuples that satisfy linear inequality constraints, but AFAIK those are not available in R. Best, 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: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith Sent: Tuesday, July 03, 2007 4:10 PM To: R-help Subject: [R] Fine tunning rgenoud Dear All, I am trying to solve the following maximization problem, but I cannot have rgenoud giving me a reliable solution. Any ideas? Thanks in advance, Paul library(rgenoud) v <- 0.90 O1 <- 10 O2 <- 20 O0 <- v*O1+(1-v)*O2 myfunc <- function(x) { U0 <- x[1] U1 <- x[2] U2 <- x[3] q0 <- x[4] q1 <- x[5] q2 <- x[6] p <- x[7] if (U0 < 0) return(-1e+200) else if (U1 < 0) return(-1e+200) else if (U2 < 0) return(-1e+200) else if ((U0-(U1+(O1-O0)*q1)) < 0) return(-1e+200) else if ((U0-(U2+(O2-O0)*q2)) < 0) return(-1e+200) else if ((U1-(U0+(O0-O1)*q0)) < 0) return(-1e+200) else if ((U1-(U2+(O2-O1)*q2)) < 0) return(-1e+200) else if((U2-(U0+(O0-O2)*q0)) < 0) return(-1e+200) else if((U2-(U1+(O1-O2)*q1)) < 0) return(-1e+200) else if(p < 0) return(-1e+200) else if(p > 1) return(-1e+200) else if(q0 < 0) return(-1e+200) else if(q1 < 0) return(-1e+200) else if(q2 < 0) return(-1e+200) else return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2 )-(O2*q2+U2 } genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene rations=150,max.generations=300,boundary.enforcement=2) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fine tunning rgenoud
On 7/3/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > You had indicated in your previous email that you are having trouble finding > a feasible starting value for constrOptim(). So, you basically need to > solve a system of linear inequalities to obtain a starting point. Have you > considered using linear programming? Either simplex() in the "boot" package > or solveLP() in "linprog" would work. It seems to me that you could use any > linear objective function in solveLP to obtain a feasible starting point. > This is not the most efficient solution, but it might be worth a try. > > I am aware of other methods for generating n-tuples that satisfy linear > inequality constraints, but AFAIK those are not available in R. Thanks, Ravi. I had already conceived the solution that you suggest, actually using "lpSolve". I am able to get a solution for my problem with constrOptim, but I am not enough confident that the solution is right. That is why I am trying to get a solution with rgenoud, but unsuccessfully until now. Paul > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith > Sent: Tuesday, July 03, 2007 4:10 PM > To: R-help > Subject: [R] Fine tunning rgenoud > > Dear All, > > I am trying to solve the following maximization problem, but I cannot > have rgenoud giving me a reliable solution. > > Any ideas? > > Thanks in advance, > > Paul > > > library(rgenoud) > > v <- 0.90 > O1 <- 10 > O2 <- 20 > O0 <- v*O1+(1-v)*O2 > > myfunc <- function(x) { > U0 <- x[1] > U1 <- x[2] > U2 <- x[3] > q0 <- x[4] > q1 <- x[5] > q2 <- x[6] > p <- x[7] > > if (U0 < 0) > return(-1e+200) > else if (U1 < 0) > return(-1e+200) > else if (U2 < 0) > return(-1e+200) > else if ((U0-(U1+(O1-O0)*q1)) < 0) > return(-1e+200) > else if ((U0-(U2+(O2-O0)*q2)) < 0) > return(-1e+200) > else if ((U1-(U0+(O0-O1)*q0)) < 0) > return(-1e+200) > else if ((U1-(U2+(O2-O1)*q2)) < 0) > return(-1e+200) > else if((U2-(U0+(O0-O2)*q0)) < 0) > return(-1e+200) > else if((U2-(U1+(O1-O2)*q1)) < 0) > return(-1e+200) > else if(p < 0) > return(-1e+200) > else if(p > 1) > return(-1e+200) > else if(q0 < 0) > return(-1e+200) > else if(q1 < 0) > return(-1e+200) > else if(q2 < 0) > return(-1e+200) > else > return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2 > )-(O2*q2+U2 > > } > genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene > rations=150,max.generations=300,boundary.enforcement=2) > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Harrell's C
Madero Jarabo, Rosario wrote: > I need to calculate Harrell's C for some survival analyses using Design > package with R version 2.4.1. ¿How can I try or do it? > > Rosario Madero > Sección de Bioestadística > Hospital Universitario La Paz > Pºde la Castellana, 261 > 28046 Madrid, España > Tfno: 917277112 > [EMAIL PROTECTED] It's in the documention with the Hmisc package. Type ?rcorr.cens ?rcorrp.cens Frank -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems using imported data
You have to read the data into an object: e.g., mydata <- read.delim("Filename.txt", header=TRUE) and then you can access the data with 'mydata'. If you had "test" as a column header,then mydata$test will access that data. On 7/3/07, Susie Iredale <[EMAIL PROTECTED]> wrote: > > > > > (Repeat of previous HTML version) > > Hello all, > > I am a new R user and I have finally imported my data using > >read.delim("Filename.txt", header=TRUE) after some difficulty, by > changing file directories (a hint to anyone who might be stuck there). > > However, I am now stuck trying to use my data. When I try to use > data.frame("filename.txt") it tells me object not found, which makes it > difficult to use attach() or with(). How do I get R to recognize my data? > > Thanks, > Susie > PhD Student UCI > > > > > > > Luggage? GPS? Comic books? > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Parsimony Analysis of Encemism in R?
Short answer: No. Longer answer: R currently has some useful but relatively limited functions for phylogenetics. See the "Statistical genetics" task view on CRAN. The ape package is the most full-featured. Simon. On Tue, 2007-07-03 at 07:59 -0700, Milton Cezar Ribeiro wrote: > Hi R-gurus, > > Is there a package for "Parsimony Analysis of Endemism" (Cladist) in R? > > Kind regards, > > Miltinho > Brazil > > > > > > http://yahoo.com.br/oqueeuganhocomisso > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320, Goddard Building (8) T: +61 7 3365 2506 email: S.Blomberg1_at_uq.edu.au 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. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fine tunning rgenoud
Paul, It should be easy enough to check that your solution is valid (i.e. a local minimum): first, check to see if the solution satisfies all the constraints; secondly, check to see if it is an interior point (i.e. none of the constraints become equality); and finally, if the solution is an interior point, check to see whether the gradient there is close to zero. Note that if the solution is one of the vertices of the polyhedron, then the gradient may not be zero. 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: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith Sent: Tuesday, July 03, 2007 5:10 PM To: R-help Subject: Re: [R] Fine tunning rgenoud On 7/3/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > You had indicated in your previous email that you are having trouble finding > a feasible starting value for constrOptim(). So, you basically need to > solve a system of linear inequalities to obtain a starting point. Have you > considered using linear programming? Either simplex() in the "boot" package > or solveLP() in "linprog" would work. It seems to me that you could use any > linear objective function in solveLP to obtain a feasible starting point. > This is not the most efficient solution, but it might be worth a try. > > I am aware of other methods for generating n-tuples that satisfy linear > inequality constraints, but AFAIK those are not available in R. Thanks, Ravi. I had already conceived the solution that you suggest, actually using "lpSolve". I am able to get a solution for my problem with constrOptim, but I am not enough confident that the solution is right. That is why I am trying to get a solution with rgenoud, but unsuccessfully until now. Paul > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith > Sent: Tuesday, July 03, 2007 4:10 PM > To: R-help > Subject: [R] Fine tunning rgenoud > > Dear All, > > I am trying to solve the following maximization problem, but I cannot > have rgenoud giving me a reliable solution. > > Any ideas? > > Thanks in advance, > > Paul > > > library(rgenoud) > > v <- 0.90 > O1 <- 10 > O2 <- 20 > O0 <- v*O1+(1-v)*O2 > > myfunc <- function(x) { > U0 <- x[1] > U1 <- x[2] > U2 <- x[3] > q0 <- x[4] > q1 <- x[5] > q2 <- x[6] > p <- x[7] > > if (U0 < 0) > return(-1e+200) > else if (U1 < 0) > return(-1e+200) > else if (U2 < 0) > return(-1e+200) > else if ((U0-(U1+(O1-O0)*q1)) < 0) > return(-1e+200) > else if ((U0-(U2+(O2-O0)*q2)) < 0) > return(-1e+200) > else if ((U1-(U0+(O0-O1)*q0)) < 0) > return(-1e+200) > else if ((U1-(U2+(O2-O1)*q2)) < 0) > return(-1e+200) > else if((U2-(U0+(O0-O2)*q0)) < 0) > return(-1e+200) > else if((U2-(U1+(O1-O2)*q1)) < 0) > return(-1e+200) > else if(p < 0) > return(-1e+200) > else if(p > 1) > return(-1e+200) > else if(q0 < 0) > return(-1e+200) > else if(q1 < 0) > return(-1e+200) > else if(q2 < 0) > return(-1e+200) > else > return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2 > )-(O2*q2+U2 > > } > genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene > rations=150,max.generations=300,boundary.enforcement=2) > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bug in closing gzfile-opened connections?
On 03/07/2007 1:37 PM, David Reiss wrote: > Hi, > I am making multiple calls to gzfile() via read.table(), e.g. > >> x <- read.table( gzfile( "xxx.gz" ) ) > > After i do this many times (I haven't counted, but probably between 50 and > 100 times) I get the error message: > > Error in open.connection(file, "r") : unable to open connection > In addition: Warning message: > cannot open compressed file 'xxx.gz' > > however, I also find that: > >> showConnections() > description class mode text isopen can read can write > > so there are no (apparently) open connections. Calling closeAllConnections() > does not fix the problem. I have to quit and re-start R. > I am using R 2.5.0 on a Mac (OSX 10.4.9). > > Anyone know if this is a bug or a 'feature'? I see from the gzfile help > that: > > In general functions using connections > will open them if they are not open, but then close them again, so > to leave a connection open call 'open' explicitly. You didn't give a reproducible example, so I couldn't say. When I create a gzipped version of a write.table output and run for(i in 1:1000) read.table(gzfile(f)) in R 2.5.0 I don't see a problem. This is on Windows, but I doubt that makes a difference. Duncan Murdoch __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fine tunning rgenoud
On 7/4/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > It should be easy enough to check that your solution is valid (i.e. a local > minimum): first, check to see if the solution satisfies all the > constraints; secondly, check to see if it is an interior point (i.e. none of > the constraints become equality); and finally, if the solution is an > interior point, check to see whether the gradient there is close to zero. > Note that if the solution is one of the vertices of the polyhedron, then the > gradient may not be zero. That is a very good idea, Ravi! Thanks! Paul > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith > Sent: Tuesday, July 03, 2007 5:10 PM > To: R-help > Subject: Re: [R] Fine tunning rgenoud > > On 7/3/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > > You had indicated in your previous email that you are having trouble > finding > > a feasible starting value for constrOptim(). So, you basically need to > > solve a system of linear inequalities to obtain a starting point. Have > you > > considered using linear programming? Either simplex() in the "boot" > package > > or solveLP() in "linprog" would work. It seems to me that you could use > any > > linear objective function in solveLP to obtain a feasible starting point. > > This is not the most efficient solution, but it might be worth a try. > > > > I am aware of other methods for generating n-tuples that satisfy linear > > inequality constraints, but AFAIK those are not available in R. > > Thanks, Ravi. I had already conceived the solution that you suggest, > actually using "lpSolve". I am able to get a solution for my problem > with constrOptim, but I am not enough confident that the solution is > right. That is why I am trying to get a solution with rgenoud, but > unsuccessfully until now. > > Paul > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith > > Sent: Tuesday, July 03, 2007 4:10 PM > > To: R-help > > Subject: [R] Fine tunning rgenoud > > > > Dear All, > > > > I am trying to solve the following maximization problem, but I cannot > > have rgenoud giving me a reliable solution. > > > > Any ideas? > > > > Thanks in advance, > > > > Paul > > > > > > library(rgenoud) > > > > v <- 0.90 > > O1 <- 10 > > O2 <- 20 > > O0 <- v*O1+(1-v)*O2 > > > > myfunc <- function(x) { > > U0 <- x[1] > > U1 <- x[2] > > U2 <- x[3] > > q0 <- x[4] > > q1 <- x[5] > > q2 <- x[6] > > p <- x[7] > > > > if (U0 < 0) > > return(-1e+200) > > else if (U1 < 0) > > return(-1e+200) > > else if (U2 < 0) > > return(-1e+200) > > else if ((U0-(U1+(O1-O0)*q1)) < 0) > > return(-1e+200) > > else if ((U0-(U2+(O2-O0)*q2)) < 0) > > return(-1e+200) > > else if ((U1-(U0+(O0-O1)*q0)) < 0) > > return(-1e+200) > > else if ((U1-(U2+(O2-O1)*q2)) < 0) > > return(-1e+200) > > else if((U2-(U0+(O0-O2)*q0)) < 0) > > return(-1e+200) > > else if((U2-(U1+(O1-O2)*q1)) < 0) > > return(-1e+200) > > else if(p < 0) > > return(-1e+200) > > else if(p > 1) > > return(-1e+200) > > else if(q0 < 0) > > return(-1e+200) > > else if(q1 < 0) > > return(-1e+200) > > else if(q2 < 0) > > return(-1e+200) > > else > > > return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2 > > )-(O2*q2+U2 > > > > } > > > genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene > > rations=150,max.generations=300,boundary.enforcement=2) > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fine tunning rgenoud
On 7/4/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > It should be easy enough to check that your solution is valid (i.e. a local > minimum): first, check to see if the solution satisfies all the > constraints; secondly, check to see if it is an interior point (i.e. none of > the constraints become equality); and finally, if the solution is an > interior point, check to see whether the gradient there is close to zero. > Note that if the solution is one of the vertices of the polyhedron, then the > gradient may not be zero. I am having bad luck: all constraints are satisfied, but the solution given by constrOptim is not interior; the gradient is not equal to zero. Paul > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith > Sent: Tuesday, July 03, 2007 5:10 PM > To: R-help > Subject: Re: [R] Fine tunning rgenoud > > On 7/3/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > > You had indicated in your previous email that you are having trouble > finding > > a feasible starting value for constrOptim(). So, you basically need to > > solve a system of linear inequalities to obtain a starting point. Have > you > > considered using linear programming? Either simplex() in the "boot" > package > > or solveLP() in "linprog" would work. It seems to me that you could use > any > > linear objective function in solveLP to obtain a feasible starting point. > > This is not the most efficient solution, but it might be worth a try. > > > > I am aware of other methods for generating n-tuples that satisfy linear > > inequality constraints, but AFAIK those are not available in R. > > Thanks, Ravi. I had already conceived the solution that you suggest, > actually using "lpSolve". I am able to get a solution for my problem > with constrOptim, but I am not enough confident that the solution is > right. That is why I am trying to get a solution with rgenoud, but > unsuccessfully until now. > > Paul > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Paul Smith > > Sent: Tuesday, July 03, 2007 4:10 PM > > To: R-help > > Subject: [R] Fine tunning rgenoud > > > > Dear All, > > > > I am trying to solve the following maximization problem, but I cannot > > have rgenoud giving me a reliable solution. > > > > Any ideas? > > > > Thanks in advance, > > > > Paul > > > > > > library(rgenoud) > > > > v <- 0.90 > > O1 <- 10 > > O2 <- 20 > > O0 <- v*O1+(1-v)*O2 > > > > myfunc <- function(x) { > > U0 <- x[1] > > U1 <- x[2] > > U2 <- x[3] > > q0 <- x[4] > > q1 <- x[5] > > q2 <- x[6] > > p <- x[7] > > > > if (U0 < 0) > > return(-1e+200) > > else if (U1 < 0) > > return(-1e+200) > > else if (U2 < 0) > > return(-1e+200) > > else if ((U0-(U1+(O1-O0)*q1)) < 0) > > return(-1e+200) > > else if ((U0-(U2+(O2-O0)*q2)) < 0) > > return(-1e+200) > > else if ((U1-(U0+(O0-O1)*q0)) < 0) > > return(-1e+200) > > else if ((U1-(U2+(O2-O1)*q2)) < 0) > > return(-1e+200) > > else if((U2-(U0+(O0-O2)*q0)) < 0) > > return(-1e+200) > > else if((U2-(U1+(O1-O2)*q1)) < 0) > > return(-1e+200) > > else if(p < 0) > > return(-1e+200) > > else if(p > 1) > > return(-1e+200) > > else if(q0 < 0) > > return(-1e+200) > > else if(q1 < 0) > > return(-1e+200) > > else if(q2 < 0) > > return(-1e+200) > > else > > > return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2 > > )-(O2*q2+U2 > > > > } > > > genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene > > rations=150,max.generations=300,boundary.enforcement=2) > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] for loop doesn't stop with upper loop value
Hi list, could anyone please educate me on the following: lst<-seq(47, 239, by=12) for(n in lst) { lower=n; upper=lower+10 for(i in lower+2 : upper) { print(paste(n, " i: ", i, " lower: ",lower, " upper :", upper)) } } does not stop when i = upper A while loop fixes this but, I still don't understand why the for loop doesn't stop when I has the value of upper for(n in lst) { lower=n; upper=lower+10 while(lower !=upper +1) { print(paste(n, " lower: ",lower, " upper :", upper)) lower=lower+1 } } Any enlightment would be most welcome. Thankx Herry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop doesn't stop with upper loop value
___ lower+2 : upper parses as lower + (2:upper). The colon operator has fairly high precedence. What you want is (lower + 2):upper -- Hong Ooi Senior Research Analyst, IAG Limited 388 George St, Sydney NSW 2000 +61 (2) 9292 1566 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Wednesday, 4 July 2007 10:01 AM To: r-help@stat.math.ethz.ch Subject: [R] for loop doesn't stop with upper loop value Hi list, could anyone please educate me on the following: lst<-seq(47, 239, by=12) for(n in lst) { lower=n; upper=lower+10 for(i in lower+2 : upper) { print(paste(n, " i: ", i, " lower: ",lower, " upper :", upper)) } } does not stop when i = upper A while loop fixes this but, I still don't understand why the for loop doesn't stop when I has the value of upper for(n in lst) { lower=n; upper=lower+10 while(lower !=upper +1) { print(paste(n, " lower: ",lower, " upper :", upper)) lower=lower+1 } } Any enlightment would be most welcome. Thankx Herry __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ___ The information transmitted in this message and its attachme...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Print grid/ggplot to a metafile
Hi Dieter Menne wrote: > Dear UseRs called Hadley, or Paul, > > I am trying to print an edited ggplot2/grid graphics to a metafile. With the > commented line below it works, but when I edit the plot by uncommenting the > line, it fails, because it's illegal to have 2 graphics in a metafile. It > works with pdf, but even then I get two plots, which is a nuisance. > > I found a workaround by using windows(); savePlot, but it only works in > interactive mode, not when called with something like (Windows) > > rterm --no-save < printit.r > > Any ideas? You can capture the ggplot drawing as a grid grob (gTree), edit that (no drawing occurs to this point), and then draw it ... gridggplot <- grid.grabExpr(print(ggplot(mtcars, aes(x=cyls)) + geom_bar())) modgridggplot <- editGrob(gridggplot, "xaxis::labels::label.text", just=c("center","center"), grep=TRUE, global=TRUE) win.metafile(file="bar.emf") grid.draw(modgridggplot) dev.off() Paul > Dieter > > #-- > library(ggplot2) > win.metafile(file="bar.emf") > mtcars$cyls = factor(mtcars$cyl, > labels=c("four\ncylinders","six\ncylinders","eight\ncylinders")) > ggplot(mtcars, aes(x=cyls)) + geom_bar() > #grid.gedit("xaxis::labels::label.text",just=c("center","center")) > dev.off() > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Dr Paul Murrell Department of Statistics The University of Auckland Private Bag 92019 Auckland New Zealand 64 9 3737599 x85392 [EMAIL PROTECTED] http://www.stat.auckland.ac.nz/~paul/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Sorting the levels of a factor
Dear Chunxu, I'm cc'ing my reply to the r-help mailing list. As I said in one of my previous replies to you, your questions really have to do with use of factors in R rather than anything specifically to do with the limma package, so they should go to a help list. The levels() function in R, when applied to a factor, is simply an extractor function. It extracts the levels attribute of the factor (a short character vector) which was setup when the factor itself was created. It doesn't change the levels in any way. For example, consider the following code: > f <- factor( c("a","b","a","b"), levels=c("b","a")) > levels(f) [1] "b" "a" The factor() function sets up the factor with levels in a certain order. The levels() function simply extracts the previously defined levels without resorting them. If targets$Class is a factor, the correct way to extract the levels is levels(targets$Class) Your use of unique() is superfluous. There is no need for you to use unique() anywhere in conjunction with factors if you are using factors correctly in R. When you use read.table() to read data into R, that function will automatically convert any character column that it finds in your file into a factor. By default, the factor levels will be the unique values of the character column in alphabetical order. If that's not what you want, you can define your factors explicitly, with levels in any order that you like, or else you can use read.table() with as.is=TRUE to suppress the creation of factors altogether. You last comment suggests that you might not be clear on the difference between the values of a factor and its levels. You refer to an 'array', but there is no array in your example. Your example shows the levels of the factor twice, in exactly the same order each time. The first row of your output is actually the values of the factor created by unique(), not the levels attribute of the factor. The reason that the levels of your factor are in alphabetical order is because you read your data using read.table() in the first place. Hope this helps Best wishes Gordon At 11:21 PM 3/07/2007, Qu, Chunxu wrote: >In our Linux cluster, unique did not sort the array but levels did. >See below. >Chunxu > > > unique(targets$Class) >[1] NormalTumor Tumor_CN Normal_CN >Levels: Normal Normal_CN Tumor Tumor_CN > > levels(unique(targets$Class)) >[1] "Normal""Normal_CN" "Tumor" "Tumor_CN" > > > >-Original Message- >From: Gordon Smyth [mailto:[EMAIL PROTECTED] >Sent: Tuesday, July 03, 2007 2:42 AM >To: Qu, Chunxu >Subject: RE: limma 2.9.17 > >Dear Chunxu, > >At 06:32 AM 3/07/2007, Qu, Chunxu wrote: ... > > if (is.factor(levels)) > > levels = levels(levels) > > > >This WILL sort the levels. > >No, this doesn't sort the levels. It simply extracts the levels >without changing their order. ... >Best wishes >Gordon > > >Chunxu __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] constraining residual variance to zero in lme or lmer
Hi All I havent seen that lme or lmer allows to specify certain constraints (although I heard one could program ones own covariance structure). Specific constraints, including one on the residual variance can be specified in sas proc mixed. In my model I want to fix the residual variance to the known value of 0. If anyone having an idea about that, I would appreciate letting me know. Thanks Toby __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] for loop doesn't stop with upper loop value
On 4/07/2007, at 12:01 PM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > Hi list, > > could anyone please educate me on the following: > > lst<-seq(47, 239, by=12) > > for(n in lst) > { > lower=n; upper=lower+10 >for(i in lower+2 : upper) >{ > print(paste(n, " i: ", i, " lower: ",lower, " upper :", upper)) >} > } > > does not stop when i = upper To see what's going on, type 239+2:249 Hints: o precedence of operators (this ain't APL) o parentheses are Good Things. cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confidenti...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problems using imported data
Actually, I believe attach() and detached() is discouraged nowadays... x <- read.delim("Filename.txt", header=TRUE) You can access your data by column: x[,1] x[,c(1,3)] or if your first column is named "Col1" and the third "Col3", x[,"Col1"] x[,c("Col1","Col3")] and you can do the same to access by row - by indices or rownames [which you can set with "rownames<-", see help("rownames<-")] Alternatively, with this type of data [created by the read.delim() function] you can also access with the following syntax: x$Col1 x$Col3 with(x,Col1) with(x,cbind(Col1,Col3)) ...hope this helps ST --- Susie Iredale <[EMAIL PROTECTED]> wrote: > > > > (Repeat of previous HTML version) > > Hello all, > > I am a new R user and I have finally imported my data using > >read.delim("Filename.txt", header=TRUE) after some difficulty, by changing > file directories (a hint to anyone who might be stuck there). > > However, I am now stuck trying to use my data. When I try to use > data.frame("filename.txt") it tells me object not found, which makes it > difficult to use attach() or with(). How do I get R to recognize my data? > > > Thanks, > Susie > PhD Student UCI > > > > > > > Luggage? GPS? Comic books? > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fine tunning rgenoud
Paul, Here is another approach: I wrote an R function that would generate interior points as starting values for constrOptim. This might work better than the LP approach, since the LP approach gives you a starting value that is on the boundary of the feasible region, i.e a vertex of the polyhedron, whereas this new approach gives you points on the interior. You can generate as many points as you wish, but the approach is brute-force and is very inefficient - it takes on the order of a 1000 tries to find one feasible point. Hope this helps, Ravi. - Original Message - From: Paul Smith <[EMAIL PROTECTED]> Date: Tuesday, July 3, 2007 7:32 pm Subject: Re: [R] Fine tunning rgenoud To: R-help > On 7/4/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > > It should be easy enough to check that your solution is valid (i.e. > a local > > minimum): first, check to see if the solution satisfies all the > > constraints; secondly, check to see if it is an interior point > (i.e. none of > > the constraints become equality); and finally, if the solution is an > > interior point, check to see whether the gradient there is close to > zero. > > Note that if the solution is one of the vertices of the polyhedron, > then the > > gradient may not be zero. > > I am having bad luck: all constraints are satisfied, but the solution > given by constrOptim is not interior; the gradient is not equal to > zero. > > Paul > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [ On Behalf Of Paul Smith > > Sent: Tuesday, July 03, 2007 5:10 PM > > To: R-help > > Subject: Re: [R] Fine tunning rgenoud > > > > On 7/3/07, Ravi Varadhan <[EMAIL PROTECTED]> wrote: > > > You had indicated in your previous email that you are having trouble > > finding > > > a feasible starting value for constrOptim(). So, you basically > need to > > > solve a system of linear inequalities to obtain a starting point. > Have > > you > > > considered using linear programming? Either simplex() in the "boot" > > package > > > or solveLP() in "linprog" would work. It seems to me that you > could use > > any > > > linear objective function in solveLP to obtain a feasible > starting point. > > > This is not the most efficient solution, but it might be worth a > try. > > > > > > I am aware of other methods for generating n-tuples that satisfy > linear > > > inequality constraints, but AFAIK those are not available in R. > > > > Thanks, Ravi. I had already conceived the solution that you suggest, > > actually using "lpSolve". I am able to get a solution for my problem > > with constrOptim, but I am not enough confident that the solution is > > right. That is why I am trying to get a solution with rgenoud, but > > unsuccessfully until now. > > > > Paul > > > > > > > > > -Original Message- > > > From: [EMAIL PROTECTED] > > > [ On Behalf Of Paul Smith > > > Sent: Tuesday, July 03, 2007 4:10 PM > > > To: R-help > > > Subject: [R] Fine tunning rgenoud > > > > > > Dear All, > > > > > > I am trying to solve the following maximization problem, but I cannot > > > have rgenoud giving me a reliable solution. > > > > > > Any ideas? > > > > > > Thanks in advance, > > > > > > Paul > > > > > > > > > library(rgenoud) > > > > > > v <- 0.90 > > > O1 <- 10 > > > O2 <- 20 > > > O0 <- v*O1+(1-v)*O2 > > > > > > myfunc <- function(x) { > > > U0 <- x[1] > > > U1 <- x[2] > > > U2 <- x[3] > > > q0 <- x[4] > > > q1 <- x[5] > > > q2 <- x[6] > > > p <- x[7] > > > > > > if (U0 < 0) > > > return(-1e+200) > > > else if (U1 < 0) > > > return(-1e+200) > > > else if (U2 < 0) > > > return(-1e+200) > > > else if ((U0-(U1+(O1-O0)*q1)) < 0) > > > return(-1e+200) > > > else if ((U0-(U2+(O2-O0)*q2)) < 0) > > > return(-1e+200) > > > else if ((U1-(U0+(O0-O1)*q0)) < 0) > > > return(-1e+200) > > > else if ((U1-(U2+(O2-O1)*q2)) < 0) > > > return(-1e+200) > > > else if((U2-(U0+(O0-O2)*q0)) < 0) > > > return(-1e+200) > > > else if((U2-(U1+(O1-O2)*q1)) < 0) > > > return(-1e+200) > > > else if(p < 0) > > > return(-1e+200) > > > else if(p > 1) > > > return(-1e+200) > > > else if(q0 < 0) > > > return(-1e+200) > > > else if(q1 < 0) > > > return(-1e+200) > > > else if(q2 < 0) > > > return(-1e+200) > > > else > > > > > > return(p*(sqrt(q0)-(O0*q0+U0))+(1-p)*(v*(sqrt(q1)-(O1*q1+U1))+(1-v)*(sqrt(q2 > > > )-(O2*q2+U2 > > > > > > } > > > > > > genoud(myfunc,nvars=7,max=T,pop.size=6000,starting.values=runif(7),wait.gene > > > rations=150,max.generations=300,boundary.enforcement=2) > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > > > > PLEASE do read the posting guide > > > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > _
[R] retrieving stats from bwplot
Hi all, I want to retrieve the stats from a 'bwplot' with one factor. I have read the help for 'panel' function and I'm aware of the option 'stats' which defaults to 'boxplot.stats' but I didn't understand it well and therefore I am unable to get what I need. Thanks in advance. Héctor Villalobos Windows XP, R 2.5.0 > bwplot(decrease ~ colpos | treatment, OrchardSprays, horizontal = FALSE,cex = > 1, panel = function(...) {panel.bwplot(decrease ~ colpos | treatment, > stats=boxplot.stats)}) Error in all(is.na(x) | is.na(y)) : argument "y" is missing, with no default In addition: Warning message: is.na() applied to non-(list or vector) in: is.na(x) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] exact AIC
On Tue, 3 Jul 2007, Selene Zárate wrote: I am using the stepAIC function on the MASS package that does model selection by exact AIC. I'm not sure what the term 'exact AIC' means, and how it differs from AIC. It doesn't, but there are approximations to AIC in use. This is explained in the book stepAIC supports (one is C_p, for example). -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595__ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] bug in closing gzfile-opened connections?
Note that the use of read.table() does make a difference. If you did x <- scan(gzfile("xxx.gz"), list("","","")) you would leave an unused connection, and showConnections(all=TRUE) would show this. There is a finite pool of connections, and in general the correct way to use them is con <- gzfile("xxx.gz") x <- scan(con, list("","","")) close(con) read.table() is the exception, so I suspect it is other things that have been done in the session that have used up the pool of connections. On Tue, 3 Jul 2007, Duncan Murdoch wrote: > On 03/07/2007 1:37 PM, David Reiss wrote: >> Hi, >> I am making multiple calls to gzfile() via read.table(), e.g. >> >>> x <- read.table( gzfile( "xxx.gz" ) ) >> >> After i do this many times (I haven't counted, but probably between 50 and >> 100 times) I get the error message: >> >> Error in open.connection(file, "r") : unable to open connection >> In addition: Warning message: >> cannot open compressed file 'xxx.gz' >> >> however, I also find that: >> >>> showConnections() >> description class mode text isopen can read can write >> >> so there are no (apparently) open connections. Calling closeAllConnections() >> does not fix the problem. I have to quit and re-start R. >> I am using R 2.5.0 on a Mac (OSX 10.4.9). >> >> Anyone know if this is a bug or a 'feature'? I see from the gzfile help >> that: >> >> In general functions using connections >> will open them if they are not open, but then close them again, so >> to leave a connection open call 'open' explicitly. > > You didn't give a reproducible example, so I couldn't say. When I > create a gzipped version of a write.table output and run > > for(i in 1:1000) read.table(gzfile(f)) > > in R 2.5.0 I don't see a problem. This is on Windows, but I doubt that > makes a difference. > > Duncan Murdoch > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] possible bug in ggplot2 v0.5.2???
On Tue, 3 Jul 2007, hadley wickham wrote: > Hi Stephane, > > The problem is that the windows graphics device doesn't support > transparent colours. You can get around this in two ways: It certainly does! Try col="transparent" (and perhaps consult your dictionary). It was news to me that the windows() graphics device worked on Linux i586. What it does not support as yet is translucent colours, and that is a restriction imposed by Windows (translucency support was introduced for Windows XP, and we still try to support older versions of Windows, unlike the MacOS people). I have been working on a workaround, so translucency support is likely to be implemented in R 2.6.0 for users of XP or later. Given that neither of the two main screen devices and neither of the standard print devices support translucency, the subject line looks correct to me: the problem surely lies in the assumptions made in ggplot2. > * export to a device that does support transparency (eg. pdf) > * use a solid fill colour : + stat_smooth(method="lm", fill="grey50") > > Hadley > > On 7/3/07, Stephane Cruveiller <[EMAIL PROTECTED]> wrote: >> Dear R-Users, >> >> I recently gave a try to the nice package ggplot2. Everything went >> well until I tried to add a smoother (using lm method for instance). >> On the graphic device the regression line is displayed but not confidence >> intervals as it should be (at least on ggplot website). I tried to do >> the job on >> both MS winXP and Linux i586: same result. Did anyone encountered this >> problem? Did I miss something? >> >> >> My R version is 2.4.1. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.