Re: [R] 95% Q-Q Plot error message
Thanks John. I have one observation data point with a value that's exactly equal to the predicted value, therefore the residual is 0. Would this be the reason you mentioned below? From: "John Fox" To: Liang Che/US/TLS/PwC@Americas-US Cc: "'Sanford Weisberg'" , Date: 11/04/2012 02:03 PM Subject:RE: [R] 95% Q-Q Plot error message Dear liang.che, I'm guessing that this is the qqPlot() function in the car package. This looks to me to be the combination of two problems: (1) You have at least one observation in your model for which the leverage (hat-value) is 1. That could happen, for example, if you have a factor in the model with only one observation at a particular level. (2) qqPlot() isn't handling that degenerate situation properly. Not only did I have to guess that you're using qqPlot() in the car package, but I had to guess what the problem is. If you read the text from r-help at the bottom of your message, you'll see that it says, "provide commented, minimal, self-contained, reproducible code." If you'd like help beyond my remarks above, you're more likely to get it if you provide the commands and data for your problem. Of course, we'll take a look at qqPlot() to see whether it's doing something unreasonable, and fix it if we find a problem. Best, John --- John Fox Senator McMaster Professor of Social Statistics Department of Sociology McMaster University Hamilton, Ontario, Canada > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] > On Behalf Of liang@us.pwc.com > Sent: Sunday, November 04, 2012 1:31 PM > To: r-help@r-project.org > Subject: [R] 95% Q-Q Plot error message > > Can someone please help with the error message below? > > Warning messages: > 1: Not plotting observations with leverage one: > 7 > 2: Not plotting observations with leverage one: > 7 > > print(qqPlot(fit),envelop=.95); > Error in model.frame.default(formula = Y ~ X - 1, drop.unused.levels = > TRUE) : > variable lengths differ (found for 'X') > In addition: Warning message: > In matrix(yhat, n, reps) : > data length [9] is not a sub-multiple or multiple of the number of rows > [8] > > Thanks! > > __ > The information transmitted, including any attachments, is intended only > for the person or entity to which it is addressed and may contain > confidential and/or privileged material. Any review, retransmission, > dissemination or other use of, or taking of any action in reliance upon, > this information by persons or entities other than the intended > recipient is prohibited, and all liability arising therefrom is > disclaimed. If you received this in error, please contact the sender and > delete the material from any computer. PricewaterhouseCoopers LLP is a > Delaware limited liability partnership. This communication may come > from PricewaterhouseCoopers LLP or one of its subsidiaries. > >[[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Fw: 95% Q-Q Plot error message
Can someone please help with the below - thanks! Warning messages: 1: Not plotting observations with leverage one: 7 2: Not plotting observations with leverage one: 7 > print(qqPlot(fit),envelop=.95); Error in model.frame.default(formula = Y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') In addition: Warning message: In matrix(yhat, n, reps) : data length [9] is not a sub-multiple or multiple of the number of rows [8] __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Q-Q Plot error message
Can someone please help with the error message below -- thanks! Warning messages: 1: Not plotting observations with leverage one: 7 2: Not plotting observations with leverage one: 7 > print(qqPlot(fit),envelop=.95); Error in model.frame.default(formula = Y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') In addition: Warning message: In matrix(yhat, n, reps) : data length [9] is not a sub-multiple or multiple of the number of rows [8] __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 95% Q-Q Plot error message
Can someone please help with the error message below? Warning messages: 1: Not plotting observations with leverage one: 7 2: Not plotting observations with leverage one: 7 > print(qqPlot(fit),envelop=.95); Error in model.frame.default(formula = Y ~ X - 1, drop.unused.levels = TRUE) : variable lengths differ (found for 'X') In addition: Warning message: In matrix(yhat, n, reps) : data length [9] is not a sub-multiple or multiple of the number of rows [8] Thanks! __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to write out this regression equation in R?
For example: How to make R write out: Balance = 2 + 3 * IntGDP + 5 * IntUnemployment + 0.3 * d1 from the table below: Balance Intercept IntGDP GDPNum IntUnemployment IntInflationd1 d2 d3 3 2 3 5 0.3 0 0 and if I have 20 rows, how to make it a batch process? thanks __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] why does R stepAIC keep unsignificant variables?
will add() or drop() function work more similarly as SAS? I understand that there are not many observation points which might cause the problem, but why can the automated process run successfully in SAS instead? From: David Winsemius To: Liang Che/US/TLS/PwC@Americas-US Cc: Date: 10/08/2012 09:10 PM Subject:Re: [R] why does R stepAIC keep unsignificant variables? On Oct 8, 2012, at 5:43 PM, liang@us.pwc.com wrote: > Ran a bunch of variables in R and the final result of StepAIC is as below: > Why are the first 5 variables kept in the stepwise result?? Are the last > 4 variables finally chosen after Stepwise? Thanks > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 1.315e-01 2.687e-01 0.490 0.63611 > Core_CPI__ 1.290e-02 7.496e-03 1.721 0.11927 > GDP_change -3.482e-03 2.075e-03 -1.678 0.12767 > Unemployment 1.209e-02 6.970e-03 1.735 0.11685 > interest -5.580e-03 3.923e-03 -1.422 0.18863 > housing 6.692e-04 5.812e-04 1.151 0.27928 > S_P 7.636e-05 3.967e-05 1.925 0.08641 . > d1 2.087e-02 6.102e-03 3.421 0.00762 ** > d2 -2.059e-02 7.331e-03 -2.808 0.02043 * > d3 -2.769e-02 6.268e-03 -4.418 0.00168 ** > --- > Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > Residual standard error: 0.008362 on 9 degrees of freedom > Multiple R-squared: 0.9534, Adjusted R-squared: 0.9069 > F-statistic: 20.48 on 9 and 9 DF, p-value: 5.866e-05 install.package(fortunes) requie(fortune) fortune(182) -- David Winsemius, MD Alameda, CA, USA __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use Lines function to draw the error bars?
one extra question How do I export the final image (with plots and lines added) into files in a batch mode for a bunch of regressions? thanks - Forwarded by Liang Che/US/TLS/PwC on 10/08/2012 08:48 PM - From: Liang Che/US/TLS/PwC To: Joseph Clark @INTL Cc: r-help@r-project.org Date: 10/08/2012 08:44 PM Subject:RE: [R] How to use Lines function to draw the error bars? thank you all for your answers i have figured out the plot i wanted - it was actually pretty easy lines(x=20:34,prd[,1],col="red",Ity=1) lines(x=20:34,prd[,2],lty=2) lines(x=20:34,prd[,3],lty=2) From: Joseph Clark To: Liang Che/US/TLS/PwC@Americas-US Cc: Date: 10/08/2012 05:30 PM Subject:RE: [R] How to use Lines function to draw the error bars? I don't have any experience with "predict", but if it returns a data frame, just capture that data frame and refer to the columns as vectors. mydata <- predict(...) plotCI( 1:nrow(mydata), y=mydata$fit, ui=mydata$upr, li=mydata$lwr ) That seems easier to me. // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T To: joeclar...@hotmail.com CC: r-help@r-project.org Subject: RE: [R] How to use Lines function to draw the error bars? From: liang@us.pwc.com Date: Mon, 8 Oct 2012 17:16:12 -0400 Thanks since the 'lwr' and 'upr' are produced from the 'predict' function, do I need to convert the table into a data frame, then define the 'lwr' and 'upr' as the objects? upr<-data.frame(prd[,3]) fix(upr) lwr<-data.frame(prd[,2]) fix(lwr) y<-data.frame(prd[,1]) fix(y) plotCI(x=1:15,y=y,uiw=upr,liw=lwr,err=x) but I got the following error message: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ In addition: Warning message: In if (err == "y") z <- y else z <- x : the condition has length > 1 and only the first element will be used From:Joseph Clark To:Liang Che/US/TLS/PwC@Americas-US Cc: Date:10/08/2012 05:06 PM Subject:RE: [R] How to use Lines function to draw the error bars? In my example code, 'fit' and 'upr' and 'lwr' are just the names of the data vectors you gave as an example. If those names aren't correct, change them to what you're actually using. You can also assign your x values to x. // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T To: joeclar...@hotmail.com CC: r-help@r-project.org Subject: RE: [R] How to use Lines function to draw the error bars? From: liang@us.pwc.com Date: Mon, 8 Oct 2012 17:00:56 -0400 thank you all plotCI is probably the closest to what I wanted to do -- draw the Confidence Interval curves around the fitted values (fit) but I got the following wrong message while I tried plotCI? Error in plotCI(x = 1:15, y = fit, ui = upr, li = lwr) : object 'upr' not found From:Joseph Clark To:Liang Che/US/TLS/PwC@Americas-US, Date:10/08/2012 04:03 PM Subject:RE: [R] How to use Lines function to draw the error bars? I typically use the function "plotCI" from the "plotrix" package for confidence intervals or error bars. The code would be: library(plotrix) plotCI( x=1:15, y=fit, ui=upr, li=lwr) // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T > To: r-help@r-project.org > From: liang@us.pwc.com > Date: Mon, 8 Oct 2012 15:11:53 -0400 > Subject: [R] How to use Lines function to draw the error bars? > > fit lwr upr > 1 218.4332 90.51019 346.3561 > 2 218.3906 90.46133 346.3198 > 3 218.3906 90.46133 346.3198 > 4 161.3982 44.85702 277.9394 > 5 192.4450 68.39903 316.4909 > 6 179.8056 56.49540 303.1158 > 7 219.5406 91.52707 347.5542 > 8 162.6761 46.65760 278.6945 > 9 193.8506 70.59838 317.1029 > 10 181.3816 58.11305 304.6502 > 11 221.2871 92.14366 350.4305 > 12 164.2947 47.91081 280.6785 > 13 195.3415 72.04109 318.6418 > 14 182.7447 58.68660 306.8028 > 15 222.5223 91.86550 353.1791 > > > I have tried > > new<-data.frame(newdata$Unemployment) > prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95) > lines (new,prd[,3],col="red",lty=2) > > but it didn't give me anything. > > thanks > > __ > The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this
Re: [R] How to use Lines function to draw the error bars?
thank you all for your answers i have figured out the plot i wanted - it was actually pretty easy lines(x=20:34,prd[,1],col="red",Ity=1) lines(x=20:34,prd[,2],lty=2) lines(x=20:34,prd[,3],lty=2) From: Joseph Clark To: Liang Che/US/TLS/PwC@Americas-US Cc: Date: 10/08/2012 05:30 PM Subject:RE: [R] How to use Lines function to draw the error bars? I don't have any experience with "predict", but if it returns a data frame, just capture that data frame and refer to the columns as vectors. mydata <- predict(...) plotCI( 1:nrow(mydata), y=mydata$fit, ui=mydata$upr, li=mydata$lwr ) That seems easier to me. // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T To: joeclar...@hotmail.com CC: r-help@r-project.org Subject: RE: [R] How to use Lines function to draw the error bars? From: liang@us.pwc.com Date: Mon, 8 Oct 2012 17:16:12 -0400 Thanks since the 'lwr' and 'upr' are produced from the 'predict' function, do I need to convert the table into a data frame, then define the 'lwr' and 'upr' as the objects? upr<-data.frame(prd[,3]) fix(upr) lwr<-data.frame(prd[,2]) fix(lwr) y<-data.frame(prd[,1]) fix(y) plotCI(x=1:15,y=y,uiw=upr,liw=lwr,err=x) but I got the following error message: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ In addition: Warning message: In if (err == "y") z <- y else z <- x : the condition has length > 1 and only the first element will be used From:Joseph Clark To:Liang Che/US/TLS/PwC@Americas-US Cc: Date:10/08/2012 05:06 PM Subject:RE: [R] How to use Lines function to draw the error bars? In my example code, 'fit' and 'upr' and 'lwr' are just the names of the data vectors you gave as an example. If those names aren't correct, change them to what you're actually using. You can also assign your x values to x. // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T To: joeclar...@hotmail.com CC: r-help@r-project.org Subject: RE: [R] How to use Lines function to draw the error bars? From: liang@us.pwc.com Date: Mon, 8 Oct 2012 17:00:56 -0400 thank you all plotCI is probably the closest to what I wanted to do -- draw the Confidence Interval curves around the fitted values (fit) but I got the following wrong message while I tried plotCI? Error in plotCI(x = 1:15, y = fit, ui = upr, li = lwr) : object 'upr' not found From:Joseph Clark To:Liang Che/US/TLS/PwC@Americas-US, Date:10/08/2012 04:03 PM Subject:RE: [R] How to use Lines function to draw the error bars? I typically use the function "plotCI" from the "plotrix" package for confidence intervals or error bars. The code would be: library(plotrix) plotCI( x=1:15, y=fit, ui=upr, li=lwr) // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T > To: r-help@r-project.org > From: liang@us.pwc.com > Date: Mon, 8 Oct 2012 15:11:53 -0400 > Subject: [R] How to use Lines function to draw the error bars? > > fit lwr upr > 1 218.4332 90.51019 346.3561 > 2 218.3906 90.46133 346.3198 > 3 218.3906 90.46133 346.3198 > 4 161.3982 44.85702 277.9394 > 5 192.4450 68.39903 316.4909 > 6 179.8056 56.49540 303.1158 > 7 219.5406 91.52707 347.5542 > 8 162.6761 46.65760 278.6945 > 9 193.8506 70.59838 317.1029 > 10 181.3816 58.11305 304.6502 > 11 221.2871 92.14366 350.4305 > 12 164.2947 47.91081 280.6785 > 13 195.3415 72.04109 318.6418 > 14 182.7447 58.68660 306.8028 > 15 222.5223 91.86550 353.1791 > > > I have tried > > new<-data.frame(newdata$Unemployment) > prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95) > lines (new,prd[,3],col="red",lty=2) > > but it didn't give me anything. > > thanks > > __ > The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries
[R] why does R stepAIC keep unsignificant variables?
Ran a bunch of variables in R and the final result of StepAIC is as below: Why are the first 5 variables kept in the stepwise result?? Are the last 4 variables finally chosen after Stepwise? Thanks Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.315e-01 2.687e-01 0.490 0.63611 Core_CPI__ 1.290e-02 7.496e-03 1.721 0.11927 GDP_change -3.482e-03 2.075e-03 -1.678 0.12767 Unemployment 1.209e-02 6.970e-03 1.735 0.11685 interest -5.580e-03 3.923e-03 -1.422 0.18863 housing 6.692e-04 5.812e-04 1.151 0.27928 S_P 7.636e-05 3.967e-05 1.925 0.08641 . d1 2.087e-02 6.102e-03 3.421 0.00762 ** d2 -2.059e-02 7.331e-03 -2.808 0.02043 * d3 -2.769e-02 6.268e-03 -4.418 0.00168 ** --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Residual standard error: 0.008362 on 9 degrees of freedom Multiple R-squared: 0.9534, Adjusted R-squared: 0.9069 F-statistic: 20.48 on 9 and 9 DF, p-value: 5.866e-05 __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use Lines function to draw the error bars?
Thanks since the 'lwr' and 'upr' are produced from the 'predict' function, do I need to convert the table into a data frame, then define the 'lwr' and 'upr' as the objects? upr<-data.frame(prd[,3]) fix(upr) lwr<-data.frame(prd[,2]) fix(lwr) y<-data.frame(prd[,1]) fix(y) plotCI(x=1:15,y=y,uiw=upr,liw=lwr,err=x) but I got the following error message: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ In addition: Warning message: In if (err == "y") z <- y else z <- x : the condition has length > 1 and only the first element will be used From: Joseph Clark To: Liang Che/US/TLS/PwC@Americas-US Cc: Date: 10/08/2012 05:06 PM Subject:RE: [R] How to use Lines function to draw the error bars? In my example code, 'fit' and 'upr' and 'lwr' are just the names of the data vectors you gave as an example. If those names aren't correct, change them to what you're actually using. You can also assign your x values to x. // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T To: joeclar...@hotmail.com CC: r-help@r-project.org Subject: RE: [R] How to use Lines function to draw the error bars? From: liang@us.pwc.com Date: Mon, 8 Oct 2012 17:00:56 -0400 thank you all plotCI is probably the closest to what I wanted to do -- draw the Confidence Interval curves around the fitted values (fit) but I got the following wrong message while I tried plotCI? Error in plotCI(x = 1:15, y = fit, ui = upr, li = lwr) : object 'upr' not found From:Joseph Clark To:Liang Che/US/TLS/PwC@Americas-US, Date:10/08/2012 04:03 PM Subject:RE: [R] How to use Lines function to draw the error bars? I typically use the function "plotCI" from the "plotrix" package for confidence intervals or error bars. The code would be: library(plotrix) plotCI( x=1:15, y=fit, ui=upr, li=lwr) // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T > To: r-help@r-project.org > From: liang@us.pwc.com > Date: Mon, 8 Oct 2012 15:11:53 -0400 > Subject: [R] How to use Lines function to draw the error bars? > > fit lwr upr > 1 218.4332 90.51019 346.3561 > 2 218.3906 90.46133 346.3198 > 3 218.3906 90.46133 346.3198 > 4 161.3982 44.85702 277.9394 > 5 192.4450 68.39903 316.4909 > 6 179.8056 56.49540 303.1158 > 7 219.5406 91.52707 347.5542 > 8 162.6761 46.65760 278.6945 > 9 193.8506 70.59838 317.1029 > 10 181.3816 58.11305 304.6502 > 11 221.2871 92.14366 350.4305 > 12 164.2947 47.91081 280.6785 > 13 195.3415 72.04109 318.6418 > 14 182.7447 58.68660 306.8028 > 15 222.5223 91.86550 353.1791 > > > I have tried > > new<-data.frame(newdata$Unemployment) > prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95) > lines (new,prd[,3],col="red",lty=2) > > but it didn't give me anything. > > thanks > > __ > The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCo
Re: [R] How to use Lines function to draw the error bars?
thank you all plotCI is probably the closest to what I wanted to do -- draw the Confidence Interval curves around the fitted values (fit) but I got the following wrong message while I tried plotCI? Error in plotCI(x = 1:15, y = fit, ui = upr, li = lwr) : object 'upr' not found From: Joseph Clark To: Liang Che/US/TLS/PwC@Americas-US, Date: 10/08/2012 04:03 PM Subject:RE: [R] How to use Lines function to draw the error bars? I typically use the function "plotCI" from the "plotrix" package for confidence intervals or error bars. The code would be: library(plotrix) plotCI( x=1:15, y=fit, ui=upr, li=lwr) // joseph w. clark , visiting research associate \\ university of nebraska at omaha - school of IS&T > To: r-help@r-project.org > From: liang@us.pwc.com > Date: Mon, 8 Oct 2012 15:11:53 -0400 > Subject: [R] How to use Lines function to draw the error bars? > > fit lwr upr > 1 218.4332 90.51019 346.3561 > 2 218.3906 90.46133 346.3198 > 3 218.3906 90.46133 346.3198 > 4 161.3982 44.85702 277.9394 > 5 192.4450 68.39903 316.4909 > 6 179.8056 56.49540 303.1158 > 7 219.5406 91.52707 347.5542 > 8 162.6761 46.65760 278.6945 > 9 193.8506 70.59838 317.1029 > 10 181.3816 58.11305 304.6502 > 11 221.2871 92.14366 350.4305 > 12 164.2947 47.91081 280.6785 > 13 195.3415 72.04109 318.6418 > 14 182.7447 58.68660 306.8028 > 15 222.5223 91.86550 353.1791 > > > I have tried > > new<-data.frame(newdata$Unemployment) > prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95) > lines (new,prd[,3],col="red",lty=2) > > but it didn't give me anything. > > thanks > > __ > The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. > > [[alternative HTML version deleted]] > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to use Lines function to draw the error bars?
Thanks -- I got this message: Error in stripchart.default(x1, ...) : invalid plotting method From: Bita Shams To: Liang Che/US/TLS/PwC@Americas-US Date: 10/08/2012 03:41 PM Subject:Re: [R] How to use Lines function to draw the error bars? try this : plot(new,prd[,3],col="red",lty=2,type=c("l")) type = c("l") is used to draw a line. function " lines" usually is used to add more lines to the plot. From: "liang@us.pwc.com" To: r-help@r-project.org Sent: Monday, October 8, 2012 10:41 PM Subject: [R] How to use Lines function to draw the error bars? fit lwrupr 1 218.4332 90.51019 346.3561 2 218.3906 90.46133 346.3198 3 218.3906 90.46133 346.3198 4 161.3982 44.85702 277.9394 5 192.4450 68.39903 316.4909 6 179.8056 56.49540 303.1158 7 219.5406 91.52707 347.5542 8 162.6761 46.65760 278.6945 9 193.8506 70.59838 317.1029 10 181.3816 58.11305 304.6502 11 221.2871 92.14366 350.4305 12 164.2947 47.91081 280.6785 13 195.3415 72.04109 318.6418 14 182.7447 58.68660 306.8028 15 222.5223 91.86550 353.1791 I have tried new<-data.frame(newdata$Unemployment) prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95) lines (new,prd[,3],col="red",lty=2) but it didn't give me anything. thanks __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] time series data failing ncv test
For a set of data showing seasonality (related to the 4th quarter), ncv test in R shows p-value of 0.008 which rejects the null hypothesis of constant-variance. How to apply White's standard error in R? thanks __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to use Lines function to draw the error bars?
fit lwrupr 1 218.4332 90.51019 346.3561 2 218.3906 90.46133 346.3198 3 218.3906 90.46133 346.3198 4 161.3982 44.85702 277.9394 5 192.4450 68.39903 316.4909 6 179.8056 56.49540 303.1158 7 219.5406 91.52707 347.5542 8 162.6761 46.65760 278.6945 9 193.8506 70.59838 317.1029 10 181.3816 58.11305 304.6502 11 221.2871 92.14366 350.4305 12 164.2947 47.91081 280.6785 13 195.3415 72.04109 318.6418 14 182.7447 58.68660 306.8028 15 222.5223 91.86550 353.1791 I have tried new<-data.frame(newdata$Unemployment) prd<-predict.lm(fit,newdata,interval=c("confidence"),level=0.95) lines (new,prd[,3],col="red",lty=2) but it didn't give me anything. thanks __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] time series data failing non-constant variance test
For a set of data showing seasonality (related to the 4th quarter), ncv test shows p-value of 0.008 which rejects the null hypothesis of constant-variance. Currently a linear LM relationship is being applied to the data. Should white's error be used to correct the non-constant variance? Are the p-values of the coefficients unreliable? thanks __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] can stepAIC be customized to exclude coefficients with p-value less than certain values?
For example, if coefficient's p-value is less than 0.1 I want the stepwise to automatically drop that variable. Can the stepAIC be customized to do that? SAS seems to be able to customized stepwise function with p-value or cooks'd. thanks! __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error in if (any(ch)) { : missing value where TRUE/FALSE needed
Can someone please help with the error message below? thanks! Start: AIC=-Inf value ~ 1 + Core_CPI__ + GDP_change + Unemployment + housing + interest + S_P + d1 + d2 + d3 Error in if (any(ch)) { : missing value where TRUE/FALSE needed In addition: Warning message: attempting model selection on an essentially perfect fit is nonsense __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] will 9 data points work for a regression in R?
See error message below: can someone please help with this? Thanks! Residuals: ALL 9 residuals are 0: no residual degrees of freedom! Residual standard error: NaN on 0 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: NaN F-statistic: NaN on 8 and 0 DF, p-value: NA __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] stepAIC in R
My stepAIC function works for one set of data but not anotherone set of data shows the steps of eliminating variables, versus another set of data doesn't throw away any variables. Can anyone please explain why? Thanks __ The information transmitted, including any attachments, is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited, and all liability arising therefrom is disclaimed. If you received this in error, please contact the sender and delete the material from any computer. PricewaterhouseCoopers LLP is a Delaware limited liability partnership. This communication may come from PricewaterhouseCoopers LLP or one of its subsidiaries. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
hey Jim. brilliant, very short and productive, wish that i can have such skill in the future, i will try to learn about all functions that you used. thanks very much for helping me, i really appreciate it. -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1460459.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
hello, i appreciate your help, your help, comments, and suggestion really are so helpful to develop not only my R skills, but also my programming language sense. as i said, i am not breaking any academic rules, and this is a softwar i have to develop to deal with my project after two months along with some algorithms .. any way, for your question jholtman, if one particular amino acids (let say letter A) is missed in the data, that wont appear in the graph. any way i think i found the clue for this work, here you are what i wrote, it is working, but i would love to have any comments, or advices. the data attached. many thanks. x<-read.table("C:/Uni/502/CA2/hiv.dat", header=TRUE) attach(x) AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') num<-nrow(x) frequency<-function(Q) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i]== Q) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y) } freqC<-frequency("cleaved") freqNc<-frequency("noncleaved") ClPeptide<-114 nClPeptide<-248 Norm<-function(F,N) { No<-matrix(0,20,8) colnames(No)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for (j in 1:8){ for (k in 1:20){ No[k,j]=(F[k,j]/N)*100 } } return(No) } normalisedC<-Norm(freqC,ClPeptide) normalisedNc<-Norm(freqNc,nClPeptide) hi<-function(H) { height<-rep(0,8) for (j in 1:8){ height[j]<-sum(round(H)[,j]) max.height<-max(height) } return(max.height) } CleH<-hi(normalisedC) nCleH<-hi(normalisedNc) colmap<-c("#009900", "#00CC00", "#00FF00", "#009933", "#00CC33", "#00FF33", "#009966", "#00CC66", "#00FF66", "#00", "#00CC99", "#00FF99", "#0099CC", "#00", "#00FFCC", "#0099FF", "#00CCFF", "#00", "#66", "#CC") CumulativeY<-function(k,b,F) { if( b<=0) { cum=0 } else { cum=0 for(d in 1:b) { cum=cum + (round(F[d,k])) } } return(cum) } graph<- function(F) { for(i in 1:8) { for(j in 1:20) { rect((i-1)*10,CumulativeY(i,j-1,F),((i-1)*10)+10,CumulativeY(i,j,F), col=colmap[j]) if ( F[j,i] != 0) { text( ((i-1)*10)+5, (CumulativeY(i,j-1,F) + round(F[j,i])/2), AA[j], cex=((2*round(F[j,i])/round(max(F,col="#99") } } } } par(mfrow=c(1,2)) plot(c(0,10*8),c(0,CleH),col="#303030") graph(normalisedC) plot(c(0,10*8),c(0,nCleH),col="#303030") graph(normalisedNc) http://n4.nabble.com/file/n1458002/hiv.dat hiv.dat -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1458002.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
Here is the the written instruction as i managed to get it from my professor, the graphs and data are attached: The graph below shows an example of the expected outcome of this course work. You may procude a better one. The graph for analysing the motifs of a set of peptides is designed this way • the graph is composed of columns of coloured rectangles • a column corresponding to a residue from “N4” to “C4”. Note that eight residues are denoted by “N4”, “N3”, “N2”, “N1”, “C1”, “C2”, “C3”, “C4”. “N4” means the 4th flanking residue of a cleavage site on the N-terminal side and “C3” means the 3rd flanking residue of a cleavage site on the C-terminal side. The cleavage occurs between “N1” and “C1”. • there are 20 rectangles in each column corresponding to 20 amino acids. A rectangular of an amino acid has a larger height if the corresponding amino acid has a larger frequency to occur at the residue, for instance, the rectangular of “S” in the first column for the cleaved peptides. • a letter of an amino acid is printed within a rectangular. Its font size depends on the frequency of the amino acid in a residue. In your package, you need to have the following functions 1. set a colour map using the following or your own design • colmap<-c("#FF", "#CC", "#99", "#66", "#33", "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33", "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933", "#FF9900", "#FF33FF", "#FF33CC") 2. define a set of amino acids using string or other format if you want • amino.acid<-"ACDEFGHIKLMNPQRSTVWY" 3. read in the given peptide data (“hiv.dat”) using read.table(‘‘../data/hiv.dat’’,header=TRUE) • The data I sent to you should not be saved in the same directory where you save your R code! • The data is composed of two parts, cleaved (denoted by “cleaved”) and non cleaved (denoted by “noncleaved”). The first five lines of the data are shown below Peptide Label TQIMFETF cleaved GQVNYEEF cleaved KVFGRCEL noncleaved VFGRCELA noncleaved • to access to the ith peptide, you can use X$Peptide[i] • to access to the ith label, you can use X$Label[i] 4. detect the number of cleaved peptides and the number of non-cleaved peptides using • nrow(X) 5. define two matrices with initialised entries, one for positive peptides and one for neg- ative peptides • matrix(0,AA,mer),where AA is the number of amino acids, and mer is the number of residues detected from data using the nchar function • both matrices have the same size, the number of rows being equal to the number of amino acids and the number of columns being equal to the number of residues in peptides • name the columns of these two matrices using – c("N4","N3","N2","N1","C1","C2","C3","C4"), 6. use one three-loop structure to detect the frequency of amino acids in cleaved peptides and one three-loop structure to detect the frequency of amino acids in non-cleaved peptides. They should not be mixed in one three-loop structure. The best way to handle this is to use a function. The three-loop structure is exampled as below for(i in 1:num)#scanning data for all peptides, where num means the number of peptides { for(j in 1:mer)#scanning all residues in a peptide { for(k in 1:AA)#scanning 20 amino acids { #actions } } } 7. make sure that each frequency matrix needs to be converted to a percentage, i.e. each entry in the matrix is divided by the number of cleaved or non-cleaved peptides and multiplied by 100. This converted frequency is named as the normalised frequency. 8. detect the maximum height of the normalised frequency each residue in cleaved or non-cleaved peptides using height<-rep(0,mer) for(j in 1:mer) height[j]<-sum(round(X.frequency[,j])) max.height<-max(height) • Note that the height of each column in a graph (see the graph on 3) corresponds to the summation of 20 frequencies of 20 amino acids for a residue. 9. draw a blank plot using the maximum height • plot(c(0,10*mer),c(0,max.height),col="white", • • •) • in this blank plot, you can add graphics as discussed below 10. determine the x coordinate, but it is recommended to use i*10 as the x-coordinate where i indexes the residues. The x-coordinate represents columns in the graph shown in 3. If there are 8 residues in peptides, there are 8 columns. 11. determine the y coordinate, which is cumulative (see next item below). The y- coordinate represents rows in the graph shown in 3. There are always 20 rows for 20 amino acids. Note that the rows cannot be aligned because the frequency of an amino acid in a residue varies. 12. draw a rectangular based on the frequency of each residue and each amino acid • rect(x,y,x+10,y+round(X.frequency[k,j]),col=colmap[k]), where k indi- cates an amino acid and j indicates a residue • after drawing this rectangular, the y-coordinate “y” should be increased by round(X.frequency[k,j]) • after one column is drawn for one residue, the x-coordinate “x” should be in- creased by 10 13. plot a text at the correspon
Re: [R] More than on loop??
yes, but the outcome graphs are almost the same, that mean it does not calculated in a cumulative way , if you apply the following code, then run hi(x), and then recta(x), you will see how the shape are similar to the frequency of Amino Acid in the matrix. i am looking for a code that can do this automatically starting from the first column ending with the last column- data attached. many thanx x<-read.table("C:/Uni/502/CA2/hiv.dat", header=TRUE) num<-nrow(x) AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') nc<-x$Label[61:308] c<-x$Label[nc] noncleaved<-function(x) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i] %in% nc) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y/274*100) } cleaved<-function(x) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i] %in% nc) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y/113*100) } hi<-function(x) { height<-rep(0,8) for (j in 1:8){ height[j]<-sum(round(cleaved(x)[,j])) max.height<-max(height) } plot(c(0,10*8),c(0,max.height+20),col="white") } suma<-function(i,j,A) { if( j<= 0) { sum<-0 } else { sum<-0 for(k in 1:j) { sum<- sum + round(A[k,i]) } } return(sum) } grafica<- function(A) { for(i in 1:8) { for(j in 1:20) { rect((i-1)*10,suma(i,j-1,A),((i-1)*10)+10,suma(i,j,A), col=colmap[j]) if ( A[j,i] != 0) { text( ((i-1)*10)+5, (suma(i,j-1,A) + round(A[j,i])/2), amino.acid[j], cex=( (2*round(A[j,i])/round(max(A)) ))) } } } } recta<-function(x) { colmap<-c("#FF", "#CC", "#99", "#66", "#33", "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33", "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933", "#FF9900", "#FF33FF", "#FF33CC") rect(1*10,20,10+10,20+round(cleaved(x)[1,1]),col=colmap[1]) rect(1*10,40,10+10,40+round(cleaved(x)[2,1]),col=colmap[2]) rect(1*10,53,10+10,53+round(cleaved(x)[3,1]),col=colmap[3]) rect(1*10,63,10+10,63+round(cleaved(x)[4,1]),col=colmap[4]) rect(1*10,69,10+10,69+round(cleaved(x)[5,1]),col=colmap[5]) rect(1*10,73,10+10,73+round(cleaved(x)[6,1]),col=colmap[6]) rect(1*10,85,10+10,85+round(cleaved(x)[7,1]),col=colmap[7]) rect(1*10,89,10+10,89+round(cleaved(x)[8,1]),col=colmap[8]) rect(1*10,96,10+10,96+round(cleaved(x)[9,1]),col=colmap[9]) rect(1*10,110,10+10,110+round(cleaved(x)[10,1]),col=colmap[10]) rect(1*10,118,10+10,118+round(cleaved(x)[11,1]),col=colmap[11]) rect(1*10,123,10+10,123+round(cleaved(x)[12,1]),col=colmap[12]) rect(1*10,144,10+10,144+round(cleaved(x)[13,1]),col=colmap[13]) rect(1*10,149,10+10,149+round(cleaved(x)[14,1]),col=colmap[14]) rect(1*10,158,10+10,158+round(cleaved(x)[15,1]),col=colmap[15]) rect(1*10,170,10+10,170+round(cleaved(x)[16,1]),col=colmap[16]) rect(1*10,198,10+10,198+round(cleaved(x)[17,1]),col=colmap[17]) rect(1*10,213,10+10,213+round(cleaved(x)[18,1]),col=colmap[18]) rect(1*10,225,10+10,225+round(cleaved(x)[19,1]),col=colmap[19]) rect(1*10,229,10+10,225+round(cleaved(x)[20,1]),col=colmap[20]) } http://n4.nabble.com/file/n1312372/hiv.dat hiv.dat http://n4.nabble.com/file/n1312372/hiv.txt hiv.txt -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1312372.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
70% yes, the problem is i am trying to produce a graph similar to the one in attachments in this message, which represents the frequency of each letter "aminoacid" in the cleaved function and the noncleaved function. some thing else i added to the attachments is the pattern which seemingly working correctly, i am trying now to create a R code to loop and simulate this pattern in order to draw all rectangles for the eight columns. But i don't know exactly how to deal with this variable which i highlighted with yellow in the image, it is cumulative in a challenging way. http://n4.nabble.com/file/n1290048/cleaved.jpg cleaved.jpg http://n4.nabble.com/file/n1290048/pattern.jpg pattern.jpg -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1290048.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
hopefully it is here, two files, one of them is .dat and the others is .txt, just in case. http://n4.nabble.com/file/n1290026/hiv.dat hiv.dat http://n4.nabble.com/file/n1290026/hiv.txt hiv.txt -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1290026.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
here you are the whole code, and the data is attached: > x<-read.table("C:/Uni/502/CA2/hiv.dat", header=TRUE) > num<-nrow(x) > AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') > nc<-x$Label[61:308] > c<-x$Label[nc] > noncleaved<-function(x) + { + y<-matrix(0,20,8) + colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") + for(i in 1:num){ + if (x$Label[i] %in% nc) + { + for(j in 1:8){ + res<-which(AA==substr(x$Peptide[i],j,j)) + y[res, j]=y[res, j]+1 + } + } + } + return (y/274*100) + } > > cleaved<-function(x) + { + y<-matrix(0,20,8) + colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") + for(i in 1:num){ + if (x$Label[i] %in% nc) + { + for(j in 1:8){ + res<-which(AA==substr(x$Peptide[i],j,j)) + y[res, j]=y[res, j]+1 + } + } + } + return (y/113*100) + } > > hi<-function(x) + { + height<-rep(0,8) + for (j in 1:8){ + height[j]<-sum(round(cleaved(x)[,j])) + max.height<-max(height) + } + plot(c(0,10*8),c(0,max.height+20),col="white") + } > recta<-function(x) + { + colmap<-c("#FF", "#CC", "#99", "#66", "#33", + "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33", + "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933", + "#FF9900", "#FF33FF", "#FF33CC") + for (j in 1:8){ + xx<-j*10 + for(k in 1:20){ + yy<-round(cleaved(x)[k,j]) + rect(xx,yy,xx+10,yy+round(cleaved(x)[k,j]),col=colmap[k]) + } + } + } -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1290019.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
can i ask your help again, please excuse my questions: It is working perfectly now, i still have the last part which i tried a lot with but still i can’t translate it properly for the computer through R. I need to draw rectangular based on the frequency of each residue, actually i found the pattern, but i am not able to translate it into an automatic R function. First, i drew an empty plot where the rectangles should be placed, then with rect function i drew the rectangles in the preferable pattern but in a manual way, i used this command for this purpose: rect(x*10,y,x+10,y+round(cleaved(x)[k,j]),col=colmap[k]) now i want to translate this pattern to an R function to go through the all data set, specially the y which i suffered with should be cumulative. hear is what i wrote, at the end i put the code which i used, but it is not working properly to translate the pattern that i made manually : hi<-function(x) { height<-rep(0,8) for (j in 1:8){ height[j]<-sum(round(cleaved(x)[,j])) max.height<-max(height) } plot(c(0,10*8),c(0,max.height+20),col="white") } recta<-function(x) { colmap<-c("#FF", "#CC", "#99", "#66", "#33", "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33", "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933", "#FF9900", "#FF33FF", "#FF33CC") rect(1*10,20,10+10,20+round(cleaved(x)[1,1]),col=colmap[1]) rect(1*10,40,10+10,40+round(cleaved(x)[2,1]),col=colmap[2]) rect(1*10,53,10+10,53+round(cleaved(x)[3,1]),col=colmap[3]) rect(1*10,63,10+10,63+round(cleaved(x)[4,1]),col=colmap[4]) rect(1*10,69,10+10,69+round(cleaved(x)[5,1]),col=colmap[5]) rect(1*10,73,10+10,73+round(cleaved(x)[6,1]),col=colmap[6]) rect(1*10,85,10+10,85+round(cleaved(x)[7,1]),col=colmap[7]) rect(1*10,89,10+10,89+round(cleaved(x)[8,1]),col=colmap[8]) rect(1*10,96,10+10,96+round(cleaved(x)[9,1]),col=colmap[9]) rect(1*10,110,10+10,110+round(cleaved(x)[10,1]),col=colmap[10]) rect(1*10,118,10+10,118+round(cleaved(x)[11,1]),col=colmap[11]) rect(1*10,123,10+10,123+round(cleaved(x)[12,1]),col=colmap[12]) rect(1*10,144,10+10,144+round(cleaved(x)[13,1]),col=colmap[13]) rect(1*10,149,10+10,149+round(cleaved(x)[14,1]),col=colmap[14]) rect(1*10,158,10+10,158+round(cleaved(x)[15,1]),col=colmap[15]) rect(1*10,170,10+10,170+round(cleaved(x)[16,1]),col=colmap[16]) rect(1*10,198,10+10,198+round(cleaved(x)[17,1]),col=colmap[17]) rect(1*10,213,10+10,213+round(cleaved(x)[18,1]),col=colmap[18]) rect(1*10,225,10+10,225+round(cleaved(x)[19,1]),col=colmap[19]) rect(1*10,229,10+10,225+round(cleaved(x)[20,1]),col=colmap[20]) } recta<-function(x) { colmap<-c("#FF", "#CC", "#99", "#66", "#33", "#00", "#FFCCFF", "#FF", "#FFCC99", "#FFCC66", "#FFCC33", "#FFCC00", "#FF99FF", "#FF99CC", "#FF", "#FF9966", "#FF9933", "#FF9900", "#FF33FF", "#FF33CC") for (j in 1:8){ xx<-j*10 for(k in 1:20){ yy<-cumsum(round(cleaved(x)[k,j])) rect(xx,yy,xx+10,yy+round(cleaved(x)[k,j]),col=colmap[k]) } } } -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1289636.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
Really thanks very much, with your help i was able to write a prober code to count the aminoacids in all the cleaved and noncleaved and then to display the results in a matrix with 8 column, i used only two loops instead of three. The code is working but i still have warning telling me that: “In if (x$Label[i] == nc) { ... : the condition has length > 1 and only the first element will be used)” So please can you help me with this warning what is the reason of it as i can’t understand exactly what does it mean? Here is the code that i am using, and the data file is attached: x<-read.table("C:/Uni/502/CA2/hiv.dat", header=TRUE) num<-nrow(x) AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') nc<-x$Label[61:308] c<-x$Label[nc] noncleaved<-function(x) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i]==nc) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y/274*100) } cleaved<-function(x) { y<-matrix(0,20,8) colnames(y)<-c("N4","N3","N2","N1","C1","C2","C3","C4") for(i in 1:num){ if (x$Label[i]==c) { for(j in 1:8){ res<-which(AA==substr(x$Peptide[i],j,j)) y[res, j]=y[res, j]+1 } } } return (y/113*100) } http://n4.nabble.com/file/n1288922/hiv.dat hiv.dat -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1288922.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] More than on loop??
Thank you very much for your help, you have been excused to have a suspicion, but dont worry i am not cheating, it is not a home work, rather it is a pre-project task that i have to deal with in order to prepare to my project, and i cant understand this programming things alone, i tried my best but still i cant deal with it properly, i am studying master and PhD in bioinformatics, and i need to develop a good understanding of programming languages. still a beginner but i start to have some fears ... what ever you send me, i study it and know exactly how it works, and believe me that can help a lot to develop my skills. Moreover i am dealing with it in a very honesty way that does not break any academic regulations. thanks again i will try what you sent me .. Yours che wrote: > > hello every one, > > How to function more than one loop in R? I have the following problem to > be solved with the a method of three loops, can you help me please? > > The data is attached with this message. > > The data is composed of two parts, cleaved (denoted by “cleaved”) and non > cleaved (denoted by “noncleaved”). > • to access to the ith peptide, you can use X$Peptide[i] > • to access to the ith label, you can use X$Label[i] > > define a set of amino acids using string or other format if you want > amino.acid<-"ACDEFGHIKLMNPQRSTVWY" > define two matrices with initialised entries, one for cleaved peptides > and one for none-cleaved peptides > • matrix(0,AA,mer),where AA is the number of amino acids, and mer is the > number > of residues detected from data using the nchar function > • both matrices have the same size, the number of rows being equal to the > number > of amino acids and the number of columns being equal to the number of > residues > in peptides > > > use one three-loop structure to detect the frequency of amino acids in > cleaved peptides > and one three-loop structure to detect the frequency of amino acids in > non-cleaved > peptides. They should not be mixed in one three-loop structure. The best > way to > handle this is to use a function. The three-loop structure is exampled as > below > for(i in 1:num)#scanning data for all peptides, where num means the number > of peptides > { > for(j in 1:mer)#scanning all residues in a peptide > { > for(k in 1:AA)#scanning 20 amino acids > { > #actions > } > } > } > http://n4.nabble.com/file/n1015851/hiv.dat hiv.dat > -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1015863.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] More than on loop??
hello every one, How to function more than one loop in R? I have the following problem to be solved with the a method of three loops, can you help me please? The data is attached with this message. The data is composed of two parts, cleaved (denoted by “cleaved”) and non cleaved (denoted by “noncleaved”). • to access to the ith peptide, you can use X$Peptide[i] • to access to the ith label, you can use X$Label[i] define a set of amino acids using string or other format if you want amino.acid<-"ACDEFGHIKLMNPQRSTVWY" define two matrices with initialised entries, one for cleaved peptides and one for none-cleaved peptides • matrix(0,AA,mer),where AA is the number of amino acids, and mer is the number of residues detected from data using the nchar function • both matrices have the same size, the number of rows being equal to the number of amino acids and the number of columns being equal to the number of residues in peptides use one three-loop structure to detect the frequency of amino acids in cleaved peptides and one three-loop structure to detect the frequency of amino acids in non-cleaved peptides. They should not be mixed in one three-loop structure. The best way to handle this is to use a function. The three-loop structure is exampled as below for(i in 1:num)#scanning data for all peptides, where num means the number of peptides { for(j in 1:mer)#scanning all residues in a peptide { for(k in 1:AA)#scanning 20 amino acids { #actions } } } http://n4.nabble.com/file/n1015851/hiv.dat hiv.dat -- View this message in context: http://n4.nabble.com/More-than-on-loop-tp1015851p1015851.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] caculate the frequencies of the Amino Acids
Thanks very much the code is working perfectly, but I hope guys that you can help me to do the same thing but by using the loop structure, i want to know if i am doing right, i want to use the loop structure to scan each sequence from the file sequence.txt (the file is attached) to get the frequency for each Amino Acid, and i wrote the following code so far, and i stopped, got confused, specially that i am a very beginner in R http://n4.nabble.com/file/n997581/sequence.txt sequence.txt : x<-read.table("sequence.txt",header=FALSE) AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') test<-nchar(as.character(x$V1[i])) frequency<-function(X) { y<-rep(0,20) for(j in 1:test){ for(i in 1:nrow(x)){ res<-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 } } return(y) } So how to fix this code, how to give the life for the “i” and the “j” in order to initiate the indexing. Sorry for bothering you guys. che wrote: > > may some one please help me to sort this out, i am trying to writ a R code > for calculating the frequencies of the amino acids in 9 different > sequences, i want the code to read the sequence from external text file, i > used the following code to do so: > x<-read.table("sequence.txt",header=FALSE) > > then i defined an array for 20 amino acids as following: > AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') > i am using the following code to calculate the frequencies: > > frequency<-function(X) > { > y<-rep(0,20) > for(j in 1:nchar(as.character(x$V1[i]))){ > for(i in 1:9){ > > res<-which(AA==substr(x$V1[i],j,j)) > y[res]=y[res]+1 > } > } > return(y) > } > > but this code actually is not working, it reads only one sequence, i dont > know why the loop is not working for the "i", which suppose to read the > nine rows of the file sequence.txt. the sequence.txt file is attached to > this message. > > cheers > http://n4.nabble.com/file/n997072/sequence.txt sequence.txt > -- View this message in context: http://n4.nabble.com/caculate-the-frequencies-of-the-Amino-Acids-tp997072p997581.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] caculate the frequencies of the Amino Acids
i know it would be better to ask R to make the data, but i need to sequence this particular file, because it is data for some Amino Acids and i cant play with, so i need to ask R to go through the sequence one by one, and then give me the numbers of each letters of each sequence, i am quite confused between using "i" and "j" and how to iterate both of them and make them work functionally. i attached the sequence.txt with my original message, and i will attach it here in case. thanks for your help. http://n4.nabble.com/file/n997087/sequence.txt sequence.txt che wrote: > > may some one please help me to sort this out, i am trying to writ a R code > for calculating the frequencies of the amino acids in 9 different > sequences, i want the code to read the sequence from external text file, i > used the following code to do so: > x<-read.table("sequence.txt",header=FALSE) > > then i defined an array for 20 amino acids as following: > AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') > i am using the following code to calculate the frequencies: > > frequency<-function(X) > { > y<-rep(0,20) > for(j in 1:nchar(as.character(x$V1[i]))){ > for(i in 1:9){ > > res<-which(AA==substr(x$V1[i],j,j)) > y[res]=y[res]+1 > } > } > return(y) > } > > but this code actually is not working, it reads only one sequence, i dont > know why the loop is not working for the "i", which suppose to read the > nine rows of the file sequence.txt. the sequence.txt file is attached to > this message. > > cheers > http://n4.nabble.com/file/n997072/sequence.txt sequence.txt > -- View this message in context: http://n4.nabble.com/caculate-the-frequencies-of-the-Amino-Acids-tp997072p997087.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] caculate the frequencies of the Amino Acids
may some one please help me to sort this out, i am trying to writ a R code for calculating the frequencies of the amino acids in 9 different sequences, i want the code to read the sequence from external text file, i used the following code to do so: x<-read.table("sequence.txt",header=FALSE) then i defined an array for 20 amino acids as following: AA<-c('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y') i am using the following code to calculate the frequencies: frequency<-function(X) { y<-rep(0,20) for(j in 1:nchar(as.character(x$V1[i]))){ for(i in 1:9){ res<-which(AA==substr(x$V1[i],j,j)) y[res]=y[res]+1 } } return(y) } but this code actually is not working, it reads only one sequence, i dont know why the loop is not working for the "i", which suppose to read the nine rows of the file sequence.txt. the sequence.txt file is attached to this message. cheers http://n4.nabble.com/file/n997072/sequence.txt sequence.txt -- View this message in context: http://n4.nabble.com/caculate-the-frequencies-of-the-Amino-Acids-tp997072p997072.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem: using cor.test with by( )
Hello everyone, I'm a new R user switching from SAS and JMP. In the first few days, I have been trying to do a fairly simple task but yet found no success. I've checked the help archive as well as few R textbooks but didn't seem to find the answer. So, please help me if you can. Basically, I want to calculate the correlation between variable A and B for every subject in my study. (yep, that simple) What I did is this: by(data, id, function (x) cor.test(A,B, data=x)) The results gave me numbers of correlation for each subject. But, the problem is that, all these correlations are the same numbers and the sample size was always the entire database (including all subjects). I've also tried the lm function instead of the cor.test, and the by() function works fine. Can any of you tell me what I did wrong? Or could you tell me what is the best way to apply a function by subjects? Thank you! Best, Che-hsu (Joe) Chang, Sc.D., P.T. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.